Changeset e7af41b in tol


Ignore:
Timestamp:
Nov 9, 2009, 1:57:31 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
2720097
Parents:
ea1b10f
Message:

Making standard package

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

Location:
tol_pkg
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/GisTools/_GisTools.tol

    rea1b10f re7af41b  
    66
    77NameBlock GisTools = [[
     8
     9Text _.autodoc.description = "Functions and classes related with "
     10"Geographic Information System (GIS), selection and classification methods "
     11"over matricial data over massive geographical points.";
     12
     13Text _.autodoc.keywords = "GIS,Geographic,select,classify";
     14
    815//////////////////////////////////////////////////////////////////////////////
    9 //Selects rows of matrix M that are inside the hipercube whose side length is
    10 //2*d and is centered in point given by row matrix P
     16Static Text _.autodoc.member.SelectRowsInHyperCube = "Selects rows of matrix "
     17"M that are inside the hipercube whose side length is 2*d and is centered in "
     18"point given by row matrix P ";
    1119Set SelectRowsInHyperCube(Matrix M, Matrix P, Real d)
    1220//////////////////////////////////////////////////////////////////////////////
    … …  
    2432
    2533//////////////////////////////////////////////////////////////////////////////
    26 //Selects rows of matrix M_ that are inside the hipersphere with specified 
    27 //ratio and is centered in point given by row matrix P
     34Static Text _.autodoc.member.SelectRowsInHyperSphere = "Selects rows of "
     35"matrix M that are inside the hipersphere with specified  ratio and is "
     36"centered in point given by row matrix P";
    2837Set SelectRowsInHyperSphere(Matrix M, Matrix P, Real ratio)
    2938//////////////////////////////////////////////////////////////////////////////
    … …  
    3948  Matrix select = VMat2Triplet(Convert(match,"Cholmod.R.Triplet"));
    4049  If(!Rows(select),Copy(Empty), MatSet(Tra(SubCol(select,[[1]])))[1])
     50};
     51
     52//////////////////////////////////////////////////////////////////////////////
     53Static Text _.autodoc.member.ClassifyColumnByRank = "Classifies a column "
     54"matrix by the ranking position respect a set of R sortednumbers. The class "
     55"of the i-th row will be assigned in this way:\n"
     56" class[i] = 1   <=>                 M[i] < rankBound[1]\n"
     57" class(i] = k+1 <=> rankBound[k] <= M[i] < rankBound[k+1]; k=1...R\n"
     58" class[i] = R+1 <=> rankBound[R] <= M[i]\n";
     59Matrix ClassifyColumnByRank(Matrix M, Set rankBound)
     60//////////////////////////////////////////////////////////////////////////////
     61{
     62  Real m = Rows(M);
     63  Real R = Card(rankBound);
     64  Real min =
     65  {
     66    Real aux = MatMin(M);
     67    aux - Abs(aux) - 1
     68  };
     69  Real max =
     70  {
     71    Real aux = MatMax(M);
     72    aux + Abs(aux) + 1
     73  };
     74  Set rnk = SetOfReal(min)<<rankBound<<SetOfReal(max);
     75  VMatrix class = Zeros(m,1);
     76  Real r = 1;
     77  While(r<=R+1,
     78  {
     79    Matrix  left  = Rand(m,1,rnk[r  ],rnk[r  ]);
     80    Matrix  right = Rand(m,1,rnk[r+1],rnk[r+1]);
     81    VMatrix left.match = Mat2VMat(LE(left,M));
     82    VMatrix right.match = Mat2VMat(LT(M,right));
     83    VMatrix class := class + And(left.match,right.match)*r;
     84    Real r := r+1
     85  });
     86  VMat2Mat(class)
    4187}
     88
    4289]];
  • tol_pkg/GraphTools/_GraphTools.tol

    rea1b10f re7af41b  
    99//////////////////////////////////////////////////////////////////////////////
    1010[[
     11
     12Text _.autodoc.description = "Functions and classes related with "
     13"Graph Theory.";
     14
     15Text _.autodoc.keywords = "Graph Theory,vertex,edge,adjacent";
     16
    1117//////////////////////////////////////////////////////////////////////////////
    1218Text _.autodoc.member.Append.Indexed = "Adds and index a new element to a "
    … …  
    220226  VMatrix _.edge.map = Rand(0,0,0,0);
    221227  VMatrix _.edge.adjacency = Rand(0,0,0,0);
    222   VMatrix _.edge.rep = Rand(0,0,0,0);
    223   Real _.edge.check.rep = ?;
    224 
     228  VMatrix _.edge.repeated = Rand(0,0,0,0);
     229  Real _.edge.check.repeated = ?;
     230  Real _.edge.check.repaired = ?;
    225231  ////////////////////////////////////////////////////////////////////////////
    226232  Static Text _.autodoc.member.New = "Creates a new instance of "
    … …  
    255261  ////////////////////////////////////////////////////////////////////////////
    256262  Text _.autodoc.member.edge.build = "";
    257   Real edge.build(Matrix data)
     263  Real edge.build(Matrix data, Real removeRepeatedEdges)
    258264  ////////////////////////////////////////////////////////////////////////////
    259265  {
    … …  
    264270    Matrix in   = If(_.directed, in_,  Max(in_, out_));
    265271    Matrix _.edge::_.data := out | in | SubCol(data,Range(3,Columns(data),1));
    266 
    267272    Matrix idx = DifEq(1/(1-B),Rand(_.edge.num,1,1,1));
    268273    Matrix idx.rep = Rand(_.edge.num,1,1,1);
    269274    Matrix outInRep = out|in|idx.rep;
    270275    VMatrix triplet.rep = Triplet(outInRep,_.vertex.num,_.vertex.num);
    271     VMatrix _.edge.rep := Convert(triplet.rep,"Cholmod.R.Sparse");
    272     Real _.edge.check.rep := VMatMax(_.edge.rep)>1;
    273     VMatrix triplet.map = If(!_.edge.check.rep,
     276    VMatrix _.edge.repeated := Convert(triplet.rep,"Cholmod.R.Sparse");
     277    VMatrix _.edge.adjacency := Or(_.edge.repeated, Zeros(_.vertex.num));
     278    VMatrix _.edge.repeated := _.edge.repeated - _.edge.adjacency;
     279    Real _.edge.check.repeated := VMatSum(_.edge.repeated);
     280    Code funTriplet = Case(
     281    !_.edge.check.repeated,
    274282    {
    275       VMatrix _.edge.adjacency := _.edge.rep;
    276       Triplet(out|in|idx,_.vertex.num,_.vertex.num)
     283      Real _.edge.check.repaired := 0;
     284      Triplet
    277285    },
     286    removeRepeatedEdges,
    278287    {
    279288      WriteLn("[GraphTools::@Graph "+_.name+"::edge.build()] "+
    280               "There are repeated edges","W");
    281       VMatrix triplet.adj = TripletUnique(outInRep,_.vertex.num,_.vertex.num);
    282       VMatrix _.edge.adjacency := Convert(triplet.adj,"Cholmod.R.Sparse");
    283       TripletUnique(out|in|idx,_.vertex.num,_.vertex.num)
     289              "There was "<<_.edge.check.repeated+
     290              " repeated edges that has been removed","W");
     291      Real _.edge.check.repaired := _.edge.check.repeated;
     292      TripletUnique
     293    },
     294    1==1,
     295    {
     296      WriteLn("[GraphTools::@Graph "+_.name+"::edge.build()] "+
     297              "There are "<<_.edge.check.repeated+" repeated edges "
     298              "but they don't will be deleted","W");
     299      Real _.edge.check.repaired := 0;
     300      Triplet
    284301    });
     302    VMatrix triplet.map = funTriplet(out|in|idx,_.vertex.num,_.vertex.num);
    285303    VMatrix _.edge.map := Convert(triplet.map,"Cholmod.R.Sparse");
    286304    True
  • tol_pkg/GraphTools/test/test_0001/define.random.graph.tol

    rea1b10f re7af41b  
    55
    66//Random seed setting
    7 Real PutRandomSeed(0);
    8 Real rndSeed = GetRandomSeed(0);
     7Real If(ObjectExist("Real","rndSeed"),
     8  PutRandomSeed(rndSeed),
     9  PutRandomSeed(0));
     10Real If(ObjectExist("Real","rndSeed"), rndSeed,
     11 rndSeed = GetRandomSeed(0));
     12
    913WriteLn("Current Random Seed = "<<rndSeed);
    1014
    11 Real vertex.num = IntRand(2,1000);
    12 Real edge.num   = IntRand(1,(vertex.num)^1.6);
    13 Real directed   = IntRand(0,1);
     15
     16Real If(ObjectExist("Real","vertex.num"), vertex.num,
     17  vertex.num = IntRand(2,100) );
     18Real If(ObjectExist("Real","edge.num"), edge.num,
     19  edge.num = IntRand(1,(vertex.num)^1.6) );
     20Real If(ObjectExist("Real","directed"), directed,
     21 directed = IntRand(0,1) );
     22Real If(ObjectExist("Real","removeRepeatedEdges"), removeRepeatedEdges,
     23 removeRepeatedEdges = IntRand(0,1) );
    1424
    1525WriteLn("Creating "+If(directed,"directed","symmetric")+
    … …  
    1727        edge.num+" edges ...");
    1828Real t0 = Copy(Time);
    19 
    2029
    2130GraphTools::@Graph graph = GraphTools::@Graph::New("test_0001",directed);
    … …  
    3746  { Hight  = Rand(edge.num, 1,  1,  10) };
    3847
    39 Real graph::edge.build(data);
     48Real graph::edge.build(data,removeRepeatedEdges);
    4049
     50Real t1 = Copy(Time);
     51
     52WriteLn("Creating time "<<(t1-t0)+" seconds");
  • tol_pkg/GraphTools/test/test_0001/test.tol

    rea1b10f re7af41b  
    1212Real numWar0 = Copy(NWarning);
    1313
     14Real rndSeed = 0;
     15Real removeRepeatedEdges = True;
    1416
    1517#Embed "../../_GraphTools.tol";
Note: See TracChangeset for help on using the changeset viewer.