source: tol/tol_pkg/GisTools/test/test_0002/test.tol @ 01f6b1c7

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

Related to #648

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1680 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: GisTools 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#Require GisTools;
17
18Real t1 = Copy(Time);
19Real rndSeed = 0;
20Real data.num = 300000;
21Real class.num =   100;
22
23Matrix Length = Rand(data.num,1,-10000,10000);
24
25WriteLn("Quantile over edge's length ... ");
26Set q.def = Range(1/class.num,1-1/class.num,1/class.num);
27Set q = MatSet(Tra(Quantile(Length, SetCol(q.def))))[1];
28Real t2 = Copy(Time);
29WriteLn("Quantile time "<<(t2-t1)+" seconds");
30
31WriteLn("ClassifyColumnByRank over edge's length... ");
32Matrix length.class = GisTools::ClassifyRowsByRank(Length, q);
33Real t3 = Copy(Time);
34WriteLn("ClassifyColumnByRank time "<<(t3-t2)+" seconds");
35
36Real q.select = IntRand(2,Card(q)-1);
37Set length.select.1 = GisTools::SelectRowsWithValue(
38  length.class,q.select-1);
39Set length.select.2 = GisTools::SelectRowsWithValue(
40  length.class,q.select);
41Set length.select.3 = GisTools::SelectRowsWithValue(
42  length.class,q.select+1);
43Set length.select.4 = GisTools::SelectRowsInInterval(
44  length.class,True,q.select-1,q.select+1,True);
45
46Matrix 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};
51Matrix aux.4 = SubRow(Length, length.select.4);
52
53Real ok.1 = MatMax(Abs(aux.123-aux.4)) == 0;
54
55Real numErr1 = Copy(NError);
56Real numWar1 = Copy(NWarning);
57
58Set partialResults_ = [[numErr0, numErr1,
59                        ok.1]];
60
61//This is a messure of the success of the test
62Real quality_ = And(numErr1 == numErr0,
63                    numWar1 <= numWar0+1,
64                    ok.1);
65
66//Return the results
67Set resultStr_ = @strTestStatus(summary_, link_, quality_,
68                  "Partial results = "<<partialResults_,
69                  "NO DBServerType", "NO DBServerHost", "NO DBAlias",
70                  email_);
71WriteLn(""<<resultStr_);
72resultStr_;
73
74/* */
75
Note: See TracBrowser for help on using the repository browser.