/* -*- mode: C++ -*- */ ////////////////////////////////////////////////////////////////////////////// // FILE : MatQuery.tol // PURPOSE: Defines package MatQuery ////////////////////////////////////////////////////////////////////////////// NameBlock MatQuery = [[ Text _.autodoc.description = "Functions and classes related with efficient " "selection and classification methods over large matricial data."; Text _.autodoc.url = ""; Set _.autodoc.keys = [["select","classify"]]; Set _.autodoc.authors = [[ "vdebuen@tol-project.org" ]]; //It will be passed to built-in function Pack to convert to the best storage //Default value is set to unknown that will ensure minimum space Real _.packSparsity = ?; ////////////////////////////////////////////////////////////////////////////// Real _checkColumnVector(Text method, VMatrix M) ////////////////////////////////////////////////////////////////////////////// { If(VColumns(M)==1,True, { WriteLn("[MatQuery::"+method+"] a column matrix was " "expected instead of ("< M[i] < rankBound[1]\n" " class(i] = k+1 <=> rankBound[k] <= M[i] < rankBound[k+1]; k=1...R\n" " class[i] = R+1 <=> rankBound[R] <= M[i]\n"; VMatrix ClassifyRowsByRank(VMatrix M, Set rankBound) ////////////////////////////////////////////////////////////////////////////// { If(!_checkColumnVector("ClassifyRowsByRank",M), Rand(0,0,0,0), { Real m = VRows(M); Real R = Card(rankBound); Real min = { Real aux = VMatMin(M); aux - Abs(aux) - 1 }; Real max = { Real aux = VMatMax(M); aux + Abs(aux) + 1 }; Set rnk = SetOfReal(min)<