Changeset 59dc492 in tol
- Timestamp:
- Nov 12, 2009, 9:04:47 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 3fd5f8b
- Parents:
- a8b5f73
- File:
-
- 1 edited
-
tol_pkg/MatQuery/MatQuery.tol (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/MatQuery/MatQuery.tol
ra8b5f73 r59dc492 14 14 "vdebuen@tol-project.org" ]]; 15 15 16 17 ////////////////////////////////////////////////////////////////////////////// 18 Text _.autodoc.member.SelectMatch = 19 "Returns the rows where thecolumn matrix 'match' has non zero value"; 20 Set SelectMatch(VMatrix match) 21 ////////////////////////////////////////////////////////////////////////////// 22 { 23 Matrix select = VMat2Triplet(Convert(match,"Cholmod.R.Triplet")); 24 If(!Rows(select),Copy(Empty), MatSet(Tra(SubCol(select,[[1]])))[1]) 25 }; 26 27 28 ////////////////////////////////////////////////////////////////////////////// 29 Text _.autodoc.member.MatchRowsWithValue = 30 "Returns a column matrix with True in rows where given column matrix M has " 31 "exactly the specified value"; 32 VMatrix MatchRowsWithValue(VMatrix M, Real value) 33 ////////////////////////////////////////////////////////////////////////////// 34 { 35 Real r = VRows(M); 36 VMatrix V = Rand(r,1,value,value); 37 EQ(M,V) 38 }; 39 16 40 ////////////////////////////////////////////////////////////////////////////// 17 41 Text _.autodoc.member.SelectRowsWithValue = … … 20 44 ////////////////////////////////////////////////////////////////////////////// 21 45 { 46 SelectMatch(MatchRowsWithValue(M,value)) 47 }; 48 49 ////////////////////////////////////////////////////////////////////////////// 50 Text _.autodoc.member.MatchRowsInInterval = 51 "Returns a column matrix with True in rows where given column matrix M is " 52 "inside the interval defined as: \n" 53 " [min,max]: if minIncluded=True and minIncluded=True\n" 54 " (min,max]: if minIncluded=False and minIncluded=True\n" 55 " [min,max): if minIncluded=True and minIncluded=False\n" 56 " (min,max): if minIncluded=False and minIncluded=False\n"; 57 VMatrix MatchRowsInInterval( 58 VMatrix M, 59 Real minIncluded, 60 Real min, 61 Real max, 62 Real maxIncluded ) 63 ////////////////////////////////////////////////////////////////////////////// 64 { 22 65 Real r = VRows(M); 23 VMatrix V = Rand(r,1,value,value); 24 VMatrix match = EQ(M,V); 25 Matrix select = VMat2Triplet(Convert(match,"Cholmod.R.Triplet")); 26 If(!Rows(select),Copy(Empty), MatSet(Tra(SubCol(select,[[1]])))[1]) 66 VMatrix Min = Rand(r,1,min,min); 67 VMatrix Max = Rand(r,1,max,max); 68 Case( 69 minIncluded & maxIncluded, And(LE(Min,M),LE(M,Max)), 70 !minIncluded & maxIncluded, And(LT(Min,M),LE(M,Max)), 71 minIncluded & !maxIncluded, And(LE(Min,M),LT(M,Max)), 72 !minIncluded & !maxIncluded, And(LT(Min,M),LT(M,Max)) 73 ) 27 74 }; 28 75 … … 43 90 ////////////////////////////////////////////////////////////////////////////// 44 91 { 92 SelectMatch(MatchRowsInInterval(M,minIncluded,min,max,maxIncluded)) 93 }; 94 95 ////////////////////////////////////////////////////////////////////////////// 96 Text _.autodoc.member.MatchRowsInHyperCube = "Returns a column matrix with " 97 "True in rows of matrix M which are inside the hipercube whose side length " 98 "is 2*d and is centered in point given by row matrix P "; 99 VMatrix MatchRowsInHyperCube(VMatrix M, VMatrix P, Real d) 100 ////////////////////////////////////////////////////////////////////////////// 101 { 45 102 Real r = VRows(M); 46 VMatrix Min = Rand(r,1,min,min); 47 VMatrix Max = Rand(r,1,max,max); 48 VMatrix match = 49 Case( 50 minIncluded & maxIncluded, And(LE(Min,M),LE(M,Max)), 51 !minIncluded & maxIncluded, And(LT(Min,M),LE(M,Max)), 52 minIncluded & !maxIncluded, And(LE(Min,M),LT(M,Max)), 53 !minIncluded & !maxIncluded, And(LT(Min,M),LT(M,Max)) 54 ); 55 Matrix select = VMat2Triplet(Convert(match,"Cholmod.R.Triplet")); 56 If(!Rows(select),Copy(Empty), MatSet(Tra(SubCol(select,[[1]])))[1]) 103 Real c = VColumns(M); 104 VMatrix D = Rand(r,1,d,d); 105 Group("And",For(1,c, VMatrix(Real k) 106 { 107 LE(Abs(SubCol(M,[[k]])-VMatDat(P,1,k)),D) 108 })) 57 109 }; 58 110 … … 64 116 ////////////////////////////////////////////////////////////////////////////// 65 117 { 66 Real r = VRows(M); 67 Real c = VColumns(M); 68 VMatrix D = Rand(r,1,d,d); 69 VMatrix match = Group("And",For(1,c, VMatrix(Real k) 70 { 71 LE(Abs(SubCol(M,[[k]])-VMatDat(P,1,k)),D) 72 })); 73 Matrix select = VMat2Triplet(Convert(match,"Cholmod.R.Triplet")); 74 If(!Rows(select),Copy(Empty), MatSet(Tra(SubCol(select,[[1]])))[1]) 118 SelectMatch(MatchRowsInHyperCube(M,P,d)) 75 119 }; 76 120 77 121 ////////////////////////////////////////////////////////////////////////////// 78 Text _.autodoc.member. SelectRowsInHyperSphere = "Selects rows of"79 " matrix M that are inside the hipersphere with specified ratio and is"80 " centered in point given by row matrix P";81 Set SelectRowsInHyperSphere(VMatrix M, VMatrix P, Real ratio)122 Text _.autodoc.member.MatchRowsInHyperSphere = "Returns a column matrix with " 123 "True in rows of matrix M which are inside the hipersphere with specified " 124 "ratio and is centered in point given by row matrix P"; 125 VMatrix MatchRowsInHyperSphere(VMatrix M, VMatrix P, Real ratio) 82 126 ////////////////////////////////////////////////////////////////////////////// 83 127 { … … 90 134 RPow(SubCol(M,[[k]])-VMatDat(P,1,k),2) 91 135 })); 92 VMatrix match = LE(dist2,R2); 93 Matrix select = VMat2Triplet(Convert(match,"Cholmod.R.Triplet")); 94 If(!Rows(select),Copy(Empty), MatSet(Tra(SubCol(select,[[1]])))[1]) 136 LE(dist2,R2) 137 }; 138 139 ////////////////////////////////////////////////////////////////////////////// 140 Text _.autodoc.member.SelectRowsInHyperSphere = "Selects rows of " 141 "matrix M that are inside the hipersphere with specified ratio and is " 142 "centered in point given by row matrix P"; 143 Set SelectRowsInHyperSphere(VMatrix M, VMatrix P, Real ratio) 144 ////////////////////////////////////////////////////////////////////////////// 145 { 146 SelectMatch(MatchRowsInHyperSphere(M,P,ratio)) 95 147 }; 96 148
Note: See TracChangeset
for help on using the changeset viewer.
