source: tol/tol_pkg/MatQuery/test/test_0002/test.tol @ 4ddca89

1941-docker-image-to-testdevel
Last change on this file since 4ddca89 was 4ddca89, checked in by Víctor de Buen <vdebuen@…>, 17 years ago

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

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/* -*- mode: C++ -*- */
2//////////////////////////////////////////////////////////////////////////////
3// FILE   : test.tol
4// PURPOSE: Package MatQuery test
5//////////////////////////////////////////////////////////////////////////////
6
7Text email_ = "vdebuen@tol-project.org";
8Text link_ = "";
9Text summary_ = "checking matrix row selection";
10
11//Write here the initial test TOL code if needed
12Real numErr0 = Copy(NError);
13Real numWar0 = Copy(NWarning);
14
15
16#Embed "../../MatQuery.tol";
17//#Require MatQuery;
18
19Real t1 = Copy(Time);
20Real rndSeed = 0;
21Real data.num = 300000;
22Real class.num =   100;
23
24VMatrix Length = Rand(data.num,1,-10000,10000);
25
26WriteLn("Quantile over edge's length ... ");
27Set q.def = Range(1/class.num,1-1/class.num,1/class.num);
28Set q = MatSet(Tra(Quantile(VMat2Mat(Length), SetCol(q.def))))[1];
29Real t2 = Copy(Time);
30WriteLn("Quantile time "<<(t2-t1)+" seconds");
31
32WriteLn("ClassifyColumnByRank over edge's length... ");
33VMatrix length.class = MatQuery::ClassifyRowsByRank(Length, q);
34Real t3 = Copy(Time);
35WriteLn("ClassifyColumnByRank time "<<(t3-t2)+" seconds");
36
37Real q.select = IntRand(2,Card(q)-1);
38Set length.select.1 = MatQuery::SelectRowsWithValue(
39  length.class,q.select-1);
40Set length.select.2 = MatQuery::SelectRowsWithValue(
41  length.class,q.select);
42Set length.select.3 = MatQuery::SelectRowsWithValue(
43  length.class,q.select+1);
44Set length.select.4 = MatQuery::SelectRowsInInterval(
45  length.class,True,q.select-1,q.select+1,True);
46
47VMatrix aux.123 =
48{
49  Set sel = length.select.1<<length.select.2<<length.select.3;
50  SubRow(Length, Sort(sel,Real(Real a, Real b) {Compare(a,b)}))
51};
52VMatrix aux.4 = SubRow(Length, length.select.4);
53
54Real ok.1 = VMatMax(Abs(aux.123-aux.4)) == 0;
55
56Real numErr1 = Copy(NError);
57Real numWar1 = Copy(NWarning);
58
59Set partialResults_ = [[numErr0, numErr1,
60                        ok.1]];
61
62//This is a messure of the success of the test
63Real quality_ = And(numErr1 == numErr0,
64                    numWar1 <= numWar0+1,
65                    ok.1);
66
67//Return the results
68Set resultStr_ = @strTestStatus(summary_, link_, quality_,
69                  "Partial results = "<<partialResults_,
70                  "NO DBServerType", "NO DBServerHost", "NO DBAlias",
71                  email_);
72WriteLn(""<<resultStr_);
73resultStr_;
74
75/* */
76
Note: See TracBrowser for help on using the repository browser.