Changeset 38b5031 in tol for tol_pkg/GisTools
- Timestamp:
- Nov 9, 2009, 3:52:18 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- f444ba5
- Parents:
- 4e5fa43
- Location:
- tol_pkg/GisTools
- Files:
-
- 2 edited
-
_GisTools.tol (modified) (4 diffs)
-
test/test_0002/test.tol (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/GisTools/_GisTools.tol
r4e5fa43 r38b5031 15 15 "vdebuen@tol-project.org" ]]; 16 16 17 ////////////////////////////////////////////////////////////////////////////// 18 Text _.autodoc.member.SelectRowsWithValue = 19 "Selects rows of a column matrix whose cell is exactly the specified value"; 20 Set 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 ////////////////////////////////////////////////////////////////////////////// 33 Text _.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"; 40 Set 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 }; 17 62 18 63 ////////////////////////////////////////////////////////////////////////////// … … 54 99 55 100 ////////////////////////////////////////////////////////////////////////////// 56 Text _.autodoc.member.Classify ColumnByRank = "Classifiesa column "101 Text _.autodoc.member.ClassifyRowsByRank = "Classifies the rows of a column " 57 102 "matrix by the ranking position respect a set of R sorted numbers. The class " 58 103 "of the i-th row will be assigned in this way:\n" … … 60 105 " class(i] = k+1 <=> rankBound[k] <= M[i] < rankBound[k+1]; k=1...R\n" 61 106 " class[i] = R+1 <=> rankBound[R] <= M[i]\n"; 62 Matrix Classify ColumnByRank(Matrix M, Set rankBound)107 Matrix ClassifyRowsByRank(Matrix M, Set rankBound) 63 108 ////////////////////////////////////////////////////////////////////////////// 64 109 { … … 90 135 } 91 136 137 92 138 ]]; -
tol_pkg/GisTools/test/test_0002/test.tol
r4e5fa43 r38b5031 18 18 Real t1 = Copy(Time); 19 19 Real rndSeed = 0; 20 Real data.num = 600000;21 Real class.num = 10;20 Real data.num = 300000; 21 Real class.num = 100; 22 22 23 23 Matrix Length = Rand(data.num,1,-10000,10000); … … 30 30 31 31 WriteLn("ClassifyColumnByRank over edge's length... "); 32 Matrix length.class = GisTools::Classify ColumnByRank(Length, q);32 Matrix length.class = GisTools::ClassifyRowsByRank(Length, q); 33 33 Real t3 = Copy(Time); 34 34 WriteLn("ClassifyColumnByRank time "<<(t3-t2)+" seconds"); 35 35 36 Real q.select = IntRand(2,Card(q)-1); 37 Set length.select.1 = GisTools::SelectRowsWithValue( 38 length.class,q.select-1); 39 Set length.select.2 = GisTools::SelectRowsWithValue( 40 length.class,q.select); 41 Set length.select.3 = GisTools::SelectRowsWithValue( 42 length.class,q.select+1); 43 Set length.select.4 = GisTools::SelectRowsInInterval( 44 length.class,True,q.select-1,q.select+1,True); 45 46 Matrix 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 }; 51 Matrix aux.4 = SubRow(Length, length.select.4); 52 53 Real ok.1 = MatMax(Abs(aux.123-aux.4)) == 0; 36 54 37 55 Real numErr1 = Copy(NError); 38 56 Real numWar1 = Copy(NWarning); 39 57 40 Set partialResults_ = [[numErr0, numErr1]]; 58 Set partialResults_ = [[numErr0, numErr1, 59 ok.1]]; 41 60 42 61 //This is a messure of the success of the test 43 62 Real quality_ = And(numErr1 == numErr0, 44 numWar1 <= numWar0+1); 63 numWar1 <= numWar0+1, 64 ok.1); 45 65 46 66 //Return the results
Note: See TracChangeset
for help on using the changeset viewer.
