Changeset 38b5031 in tol


Ignore:
Timestamp:
Nov 9, 2009, 3:52:18 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
f444ba5
Parents:
4e5fa43
Message:

New methods SelectRowsWithValue, SelectRowsInInterval
ClassifyColumnByRank is renamed as ClassifyRowsByRank

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

Location:
tol_pkg/GisTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/GisTools/_GisTools.tol

    r4e5fa43 r38b5031  
    1515   "vdebuen@tol-project.org"   ]];
    1616
     17//////////////////////////////////////////////////////////////////////////////
     18Text _.autodoc.member.SelectRowsWithValue =
     19"Selects rows of a column matrix whose cell is exactly the specified value";
     20Set SelectRowsWithValue(Matrix M, Real value)
     21//////////////////////////////////////////////////////////////////////////////
     22{
     23  Real r = Rows(M);
     24  VMatrix V = Rand(r,1,value,value);
     25  VMatrix vM = Mat2VMat(M);
     26  VMatrix match = EQ(vM,V);
     27  Matrix select = VMat2Triplet(Convert(match,"Cholmod.R.Triplet"));
     28  If(!Rows(select),Copy(Empty), MatSet(Tra(SubCol(select,[[1]])))[1])
     29};
     30
     31
     32//////////////////////////////////////////////////////////////////////////////
     33Text _.autodoc.member.SelectRowsInInterval =
     34"Selects rows of a column matrix whose cell is inside the interval defined "
     35"as: \n"
     36"  [min,max]: if minIncluded=True  and minIncluded=True\n"
     37"  (min,max]: if minIncluded=False and minIncluded=True\n"
     38"  [min,max): if minIncluded=True  and minIncluded=False\n"
     39"  (min,max): if minIncluded=False and minIncluded=False\n";
     40Set SelectRowsInInterval(
     41 Matrix M,
     42 Real minIncluded,
     43 Real min,
     44 Real max,
     45 Real maxIncluded )
     46//////////////////////////////////////////////////////////////////////////////
     47{
     48  Real r = Rows(M);
     49  VMatrix Min = Rand(r,1,min,min);
     50  VMatrix Max = Rand(r,1,max,max);
     51  VMatrix vM = Mat2VMat(M);
     52  VMatrix match =
     53  Case(
     54     minIncluded &  maxIncluded, And(LE(Min,vM),LE(vM,Max)),
     55    !minIncluded &  maxIncluded, And(LT(Min,vM),LE(vM,Max)),
     56     minIncluded & !maxIncluded, And(LE(Min,vM),LT(vM,Max)),
     57    !minIncluded & !maxIncluded, And(LT(Min,vM),LT(vM,Max))
     58  );
     59  Matrix select = VMat2Triplet(Convert(match,"Cholmod.R.Triplet"));
     60  If(!Rows(select),Copy(Empty), MatSet(Tra(SubCol(select,[[1]])))[1])
     61};
    1762
    1863//////////////////////////////////////////////////////////////////////////////
    … …  
    5499
    55100//////////////////////////////////////////////////////////////////////////////
    56 Text _.autodoc.member.ClassifyColumnByRank = "Classifies a column "
     101Text _.autodoc.member.ClassifyRowsByRank = "Classifies the rows of a column "
    57102"matrix by the ranking position respect a set of R sorted numbers. The class "
    58103"of the i-th row will be assigned in this way:\n"
    … …  
    60105" class(i] = k+1 <=> rankBound[k] <= M[i] < rankBound[k+1]; k=1...R\n"
    61106" class[i] = R+1 <=> rankBound[R] <= M[i]\n";
    62 Matrix ClassifyColumnByRank(Matrix M, Set rankBound)
     107Matrix ClassifyRowsByRank(Matrix M, Set rankBound)
    63108//////////////////////////////////////////////////////////////////////////////
    64109{
    … …  
    90135}
    91136
     137
    92138]];
  • tol_pkg/GisTools/test/test_0002/test.tol

    r4e5fa43 r38b5031  
    1818Real t1 = Copy(Time);
    1919Real rndSeed = 0;
    20 Real data.num = 600000;
    21 Real class.num = 10;
     20Real data.num = 300000;
     21Real class.num =   100;
    2222
    2323Matrix Length = Rand(data.num,1,-10000,10000);
    … …  
    3030
    3131WriteLn("ClassifyColumnByRank over edge's length... ");
    32 Matrix length.class = GisTools::ClassifyColumnByRank(Length, q);
     32Matrix length.class = GisTools::ClassifyRowsByRank(Length, q);
    3333Real t3 = Copy(Time);
    3434WriteLn("ClassifyColumnByRank time "<<(t3-t2)+" seconds");
    3535
     36Real q.select = IntRand(2,Card(q)-1);
     37Set length.select.1 = GisTools::SelectRowsWithValue(
     38  length.class,q.select-1);
     39Set length.select.2 = GisTools::SelectRowsWithValue(
     40  length.class,q.select);
     41Set length.select.3 = GisTools::SelectRowsWithValue(
     42  length.class,q.select+1);
     43Set length.select.4 = GisTools::SelectRowsInInterval(
     44  length.class,True,q.select-1,q.select+1,True);
     45
     46Matrix aux.123 =
     47{
     48  Set sel = length.select.1<<length.select.2<<length.select.3;
     49  SubRow(Length, Sort(sel,Real(Real a, Real b) {Compare(a,b)}))
     50};
     51Matrix aux.4 = SubRow(Length, length.select.4);
     52
     53Real ok.1 = MatMax(Abs(aux.123-aux.4)) == 0;
    3654
    3755Real numErr1 = Copy(NError);
    3856Real numWar1 = Copy(NWarning);
    3957
    40 Set partialResults_ = [[numErr0, numErr1]];
     58Set partialResults_ = [[numErr0, numErr1,
     59                        ok.1]];
    4160
    4261//This is a messure of the success of the test
    4362Real quality_ = And(numErr1 == numErr0,
    44                     numWar1 <= numWar0+1);
     63                    numWar1 <= numWar0+1,
     64                    ok.1);
    4565
    4666//Return the results
Note: See TracChangeset for help on using the changeset viewer.