Changeset bf5e53b in tol


Ignore:
Timestamp:
Dec 11, 2009, 9:41:52 AM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
a1affcf
Parents:
e571dbe
Message:

New method SortAndCount

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/MatQuery/MatQuery.tol

    re571dbe rbf5e53b  
    213213  });
    214214  class
    215 })}
    216 
    217 
     215})};
     216
     217//////////////////////////////////////////////////////////////////////////////
     218Text _.autodoc.member.SortAndCount = "Sorts the rows of a column matrix and "
     219"returns a matrix with two columns. The first one contains sorted unique "
     220"values found in given matrixand second one conatins the number of times "
     221"that this value is presented.";
     222VMatrix SortAndCount(VMatrix A)
     223//////////////////////////////////////////////////////////////////////////////
     224{
     225  Matrix B = VMat2Mat(A);
     226  VMatrix C = Mat2VMat(PivotByRows(B,Sort(B,[[1]])));
     227  Real m = VRows(C);
     228  Set change = Col2Set(Sort(VMat2Mat(C),[[1]],True));
     229  Set next = ExtractByIndex(change,Range(2,Card(change),1))<<[[Real m+1]];
     230  VMatrix aux.1 = DifEq(1/(1-B),Rand(m+1,1,1,1));
     231  VMatrix aux.2 = SubRow(aux.1,change);
     232  VMatrix aux.3 = SubRow(aux.1,next);
     233  SubRow(C,change) | (aux.3-aux.2)
     234}
    218235
    219236]];
Note: See TracChangeset for help on using the changeset viewer.