Changeset 3c5b71c in tol


Ignore:
Timestamp:
Mar 6, 2012, 9:36:06 AM (15 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
c42f354
Parents:
abbbbef
Message:

Refs #1136

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

Location:
tol/btol/bmodel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/bmodel/estim.cpp

    rabbbbef r3c5b71c  
    20732073}
    20742074
     2075
     2076
     2077
     2078
     2079BPolyn<BDat> ReversePolyn(const BPolyn<BDat>& p);
     2080void VectorToSchur(BPolyn<BDat>& p, const BArray<BDat>& v, int n, int n0);
     2081void SchurToVector(BArray<BDat>& v, const BPolyn<BDat>& p, int n0);
     2082
     2083//--------------------------------------------------------------------
     2084DeclareContensClass(BPol, BPolTemporary, BPolUncVec2SttPol);
     2085DefExtOpr(1, BPolUncVec2SttPol, "UncVec2SttPol", 2, 3,
     2086  "Matrix Real Real",
     2087  "(Matrix vec, Real period [, Real iniPos] )",
     2088  "Returns the stationary polynomial represented by an unconstrained "
     2089  "vector. The inverse function is SttPol2UncVec.",
     2090        BOperClassify::Sthocastic_);
     2091//--------------------------------------------------------------------
     2092void BPolUncVec2SttPol::CalcContens()
     2093//--------------------------------------------------------------------
     2094{
     2095  BMatrix<BDat>& V = Mat(Arg(1));
     2096  const BArray<BDat>& vec = V.Data();
     2097  int n = vec.Size();
     2098  if(n==0) { contens_ = BPolyn<BDat>::One(); }
     2099  else
     2100  {
     2101    int period = (int)Real(Arg(2));
     2102    int iniPos = 0;
     2103    if(Arg(3)) { iniPos = (int)Real(Arg(3)); }
     2104    int d;
     2105    BPolyn<BDat> q;
     2106    VectorToSchur(q, vec, n, iniPos);
     2107    for(d = 0; d<q.Size(); d++) { q(d).PutDegree(q(d).Degree()*period); }
     2108    contens_ = ReversePolyn(q);
     2109  }
     2110}
     2111
     2112
     2113//--------------------------------------------------------------------
     2114DeclareContensClass(BMat, BMatTemporary, BMatSttPol2UncVec);
     2115DefExtOpr(1, BMatSttPol2UncVec, "SttPol2UncVec", 2, 2, "Polyn Real",
     2116  "(Polyn pol, Real period)",
     2117  "Returns the unconstrained column vector representing an stationary "
     2118  "polynomial. The inverse function is UncVec2SttPol.",
     2119        BOperClassify::Sthocastic_);
     2120//--------------------------------------------------------------------
     2121void BMatSttPol2UncVec::CalcContens()
     2122//--------------------------------------------------------------------
     2123{
     2124  BPolyn<BDat>& pol = Pol(Arg(1));
     2125  int period =(int)Real(Arg(2));
     2126  int n = pol.Degree()/period;
     2127  if(n<=0)
     2128  {
     2129    contens_.Alloc(0,1);
     2130  }
     2131  else
     2132  {
     2133    contens_.Alloc(n,1);
     2134    BArray<BDat>& vec = contens_.GetData();
     2135    int d;
     2136    BPolyn<BDat> q = pol;
     2137    for(d = 0; d<q.Size(); d++) { q(d).PutDegree(q(d).Degree()/period); }
     2138    q = ReversePolyn(q);
     2139    SchurToVector(vec, q, 0);
     2140  }
     2141}
     2142
  • tol/btol/bmodel/modcalc.cpp

    rabbbbef r3c5b71c  
    818818
    819819//--------------------------------------------------------------------
    820 static BPolyn<BDat> ReversePolyn(const BPolyn<BDat>& p)
     820BPolyn<BDat> ReversePolyn(const BPolyn<BDat>& p)
    821821//--------------------------------------------------------------------
    822822{
    … …  
    829829
    830830//--------------------------------------------------------------------
    831 static void SchurToVector(BArray<BDat>& v, const BPolyn<BDat>& p, int n0)
     831void SchurToVector(BArray<BDat>& v, const BPolyn<BDat>& p, int n0)
    832832//--------------------------------------------------------------------
    833833{
    … …  
    864864
    865865//--------------------------------------------------------------------
    866 static void VectorToSchur(BPolyn<BDat>& p, const BArray<BDat>& v, int n, int n0)
     866void VectorToSchur(BPolyn<BDat>& p, const BArray<BDat>& v, int n, int n0)
    867867//--------------------------------------------------------------------
    868868{
Note: See TracChangeset for help on using the changeset viewer.