Changeset 90b9e0c in tol


Ignore:
Timestamp:
Sep 17, 2009, 2:08:10 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
b184182
Parents:
077124f
Message:

Preparing for new modular parser

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1396 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/_import.tol

    r077124f r90b9e0c  
    8282
    8383///////////////////////////////////////////////////////////////////////////
    84 Real Write.Header(NameBlock model, Real fileHandler)
     84Real Write.Header(NameBlock model, Real fileHandler, Text module.type)
    8585///////////////////////////////////////////////////////////////////////////
    8686{
    … …  
    9898    "$BEGIN\n"
    9999    "\n"+
     100    "Module.Type = "+module.type+";\n"
    100101    "Model.Name = \""+model.name+"\";\n"
    101102    "Model.Description = \""+Replace(model.desc,"\n","\\n\"\n\"")+"\";\n"
    … …  
    382383
    383384//////////////////////////////////////////////////////////////////////////////
    384 Text _.autodoc.member.Write =
     385Text _.autodoc.member.Write.Primary =
    385386"Imports data from a model defined by a NameBlock having a set of mandatory "
    386387"methods to get all needed information to write an ASCII file with BSR "
    387388"format that will can be readed by function BSR.Parse ";
    388   Text Write(NameBlock model)
     389  Text Write.Primary(NameBlock model)
     390//////////////////////////////////////////////////////////////////////////////
     391{
     392  Text model.name = model::Get.Doc.Model.Name(0);
     393  Text session.name = model::Get.Doc.Session.Name(0);
     394  Text path = model::Get.Doc.Path(0);
     395  Real Do OSDirMake(path);
     396
     397  Text file.bsr = path+model.name+"."+session.name+".bsr";
     398  Real f.bsr = FOpen(file.bsr,"w");
     399  Real If(!f.bsr, Real{
     400      WriteLn(_MID+"Cannot open "+file.bsr+" for writing.","E");
     401      Real Stop
     402    });
     403  WriteLn(_MID+"File "+file.bsr+" was open successfully.");
     404
     405  Real numSegment = model::Get.LinReg.Size(0);
     406  NameBlock segment = model::Get.LinReg.Segment(0);
     407
     408  Real Write.Header                    (model,   f.bsr, "primary");
     409  Real Write.Header.MainLinearBlock    (model,   f.bsr);
     410  Real Write.Data.MainLinearBlock      (segment, f.bsr);
     411  Real Write.Header.NoiseDistribution  (model,   f.bsr);
     412  Real Write.Data.NoiseDistribution    (segment, f.bsr);
     413  Real Write.Header.RegressionMatrices (model,   f.bsr);
     414  Real Write.Data.RegressionMatrices   (segment, f.bsr);
     415  Real Write.Header.MissingBlock       (model,   f.bsr);
     416  Real Write.Data.MissingBlock         (segment, f.bsr);
     417  Real FPutText(f.bsr,"\n$END\n");
     418  file.bsr
     419};
     420
     421//////////////////////////////////////////////////////////////////////////////
     422Text _.autodoc.member.Write.Joint =
     423"Imports data from a model defined by a NameBlock having a set of mandatory "
     424"methods to get all needed information to write an ASCII file with BSR "
     425"format that will can be readed by function BSR.Parse ";
     426  Text Write.Joint(NameBlock model)
    389427//////////////////////////////////////////////////////////////////////////////
    390428{
    … …  
    409447  Real f.con  = FOpen(file.bsr+".con", "w");
    410448
    411   Real Write.Header                    (model, f.head);
     449  Real Write.Header                    (model, f.head, "joint");
    412450  Real Write.Header.MainLinearBlock    (model, f.lin);
    413451  Real Write.Header.MissingBlock       (model, f.mis);
    … …  
    454492  Real OSFilRemove(file.bsr+".con");
    455493  file.bsr
     494};
     495
     496//////////////////////////////////////////////////////////////////////////////
     497Text _.autodoc.member.Write =
     498"Imports data from a model defined by a NameBlock having a set of mandatory "
     499"methods to get all needed information to write an ASCII file with BSR "
     500"format that will can be readed by function BSR.Parse ";
     501  Text Write(NameBlock model)
     502//////////////////////////////////////////////////////////////////////////////
     503{
     504  Text moduleType = ToLower(If(!FunctionExist("Text","model::Get.ModuleType"),
     505  {
     506    "joint"
     507  },
     508  {
     509    model::Get.ModuleType(0)
     510  }));
     511  Case
     512  (
     513    moduleType=="primary", Write.Primary(model),
     514    moduleType=="joint",   Write.Joint  (model),
     515    moduleType=="master",  Write.Master (model),
     516    1==1,
     517    {
     518      Error("Invalid module type '"+moduleType+"' should be one of these "
     519            "'primary', 'joint' or 'master'")
     520    }
     521  )
    456522}
    457523
     524
    458525]];
    459526
  • tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/_oneNode.tol

    r077124f r90b9e0c  
    240240    //Building generic model definition
    241241    Set modelDef = BSR.ModelDef (
     242      "joint",
    242243      docInfo = data::_.docInfo,
    243244      linearBlock,
Note: See TracChangeset for help on using the changeset viewer.