Changeset 345a4d7 in tol for tol_pkg


Ignore:
Timestamp:
Nov 27, 2009, 10:15:30 AM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
aa1e2cc
Parents:
29c0882
Message:

New method MatchRowsFullKnown
New private method _checkColumnVector
New member Real _.packSparsity

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/MatQuery/MatQuery.tol

    r29c0882 r345a4d7  
    1414   "vdebuen@tol-project.org"   ]];
    1515
     16//It will be passed to built-in function Pack to convert to the best storage
     17//Default value is set to unknown that will ensure minimum space
     18Real _.packSparsity = ?;
     19
     20//////////////////////////////////////////////////////////////////////////////
     21Real _checkColumnVector(Text method, VMatrix M)
     22//////////////////////////////////////////////////////////////////////////////
     23{
     24  If(VColumns(M)==1,True,
     25  {
     26    WriteLn("[MatQuery::"+method+"] a column matrix was "
     27    "expected instead of ("<<VRows(M)+"x"+VColumns(M)+")","E");
     28    False
     29  })
     30};
    1631
    1732//////////////////////////////////////////////////////////////////////////////
    … …  
    2136//////////////////////////////////////////////////////////////////////////////
    2237{
     38  If(!_checkColumnVector("SelectMatch",match),Copy(Empty), {
    2339  Matrix select = VMat2Triplet(Convert(match,"Cholmod.R.Triplet"));
    2440  If(!Rows(select),Copy(Empty), MatSet(Tra(SubCol(select,[[1]])))[1])
    25 };
    26 
     41})};
     42
     43//////////////////////////////////////////////////////////////////////////////
     44Text _.autodoc.member.MatchRowsFullKnown =
     45"Returns a column matrix with True in rows where all cells have konwn values";
     46VMatrix MatchRowsFullKnown(VMatrix M)
     47//////////////////////////////////////////////////////////////////////////////
     48{
     49  Real m = VRows(M);
     50  Real n = VColumns(M);
     51  Pack(Not(IsUnknown(M)*Rand(n,1,1,1)),_.packSparsity)
     52};
    2753
    2854//////////////////////////////////////////////////////////////////////////////
    … …  
    3359//////////////////////////////////////////////////////////////////////////////
    3460{
    35   If(IsUnknown(value), IsUnknown(M),
     61  If(!_checkColumnVector("MatchRowsWithValue",M), Rand(0,0,0,0), {
     62  Pack(If(IsUnknown(value), IsUnknown(M),
    3663  {
    3764    Real r = VRows(M);
    3865    VMatrix V = Rand(r,1,value,value);
    3966    EQ(M,V)
    40   })
    41 };
     67  }),_.packSparsity)
     68})};
    4269
    4370//////////////////////////////////////////////////////////////////////////////
    … …  
    6693//////////////////////////////////////////////////////////////////////////////
    6794{
     95  If(!_checkColumnVector("MatchRowsInInterval",M), Rand(0,0,0,0), {
    6896  Real r = VRows(M);
    6997  VMatrix Min = Rand(r,1,min,min);
    7098  VMatrix Max = Rand(r,1,max,max);
    71   Case(
     99  Pack(Case(
    72100     minIncluded &  maxIncluded, And(LE(Min,M),LE(M,Max)),
    73101    !minIncluded &  maxIncluded, And(LT(Min,M),LE(M,Max)),
    74102     minIncluded & !maxIncluded, And(LE(Min,M),LT(M,Max)),
    75103    !minIncluded & !maxIncluded, And(LT(Min,M),LT(M,Max))
    76   )
    77 };
     104  ),_.packSparsity)
     105})};
    78106
    79107//////////////////////////////////////////////////////////////////////////////
    … …  
    108136  Group("And",For(1,c, VMatrix(Real k)
    109137  {
    110     LE(Abs(SubCol(M,[[k]])-VMatDat(P,1,k)),D)
     138    Pack(LE(Abs(SubCol(M,[[k]])-VMatDat(P,1,k)),D), _.packSparsity)
    111139  }))
    112140};
    … …  
    137165    RPow(SubCol(M,[[k]])-VMatDat(P,1,k),2)
    138166  }));
    139   LE(dist2,R2)
     167  Pack(LE(dist2,R2),_.packSparsity)
    140168};
    141169
    … …  
    160188//////////////////////////////////////////////////////////////////////////////
    161189{
     190  If(!_checkColumnVector("ClassifyRowsByRank",M), Rand(0,0,0,0), {
    162191  Real m = VRows(M);
    163192  Real R = Card(rankBound);
    … …  
    184213  });
    185214  class
    186 }
     215})}
     216
    187217
    188218
Note: See TracChangeset for help on using the changeset viewer.