Changeset a392913 in tol


Ignore:
Timestamp:
Nov 13, 2009, 4:09:17 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
cc77af9
Parents:
95ca6b7
Message:

Using VMatrix wen possible
New methods match.feature.in.interval, extract.feature, extract.feature.rows

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/MatEncode/MatEncode.tol

    r95ca6b7 ra392913  
    1010[[
    1111
    12 #Require HashMap;
    13 #Require MatQuery;
     12  #Require HashMap;
     13  #Require MatQuery;
    1414
    1515Text _.autodoc.description = "Handling and storing generic features, "
    … …  
    3737  Static Text _.autodoc.member.get = "Returns the stored value corresponding "
    3838  "to this feature related to an individual entity.";
    39   Anything get(Matrix store, Real entity)
     39  Anything get(VMatrix store, Real entity)
    4040  ////////////////////////////////////////////////////////////////////////////
    4141};
    … …  
    6565 
    6666  ////////////////////////////////////////////////////////////////////////////
    67   Anything get(Matrix store, Real entity)
    68   ////////////////////////////////////////////////////////////////////////////
    69   {
    70     MatDat(store, entity, _.position)
     67  Anything get(VMatrix store, Real entity)
     68  ////////////////////////////////////////////////////////////////////////////
     69  {
     70    VMatDat(store, entity, _.position)
    7171  }
    7272};
    … …  
    103103
    104104  ////////////////////////////////////////////////////////////////////////////
    105   Anything get(Matrix store, Real entity)
    106   ////////////////////////////////////////////////////////////////////////////
    107   {
    108     Real idx = MatDat(store, entity, _.position);
     105  Anything get(VMatrix store, Real entity)
     106  ////////////////////////////////////////////////////////////////////////////
     107  {
     108    Real idx = VMatDat(store, entity, _.position);
    109109    _.domain[idx]
    110110  };
    … …  
    126126  //In each row of this matrix are stored the values or indexes of features
    127127  //related to an individual entity
    128   Matrix _.data = Rand(0,0,0,0);
     128  VMatrix _.data = Rand(0,0,0,0);
    129129
    130130  ////////////////////////////////////////////////////////////////////////////
    … …  
    162162
    163163  ////////////////////////////////////////////////////////////////////////////
    164   Text _.autodoc.member.feature.index = "Returns the index of a feature or 0 "
    165   "if it not exists";
    166   Real feature.index(Text name)
     164  Text _.autodoc.member.get.feature.index = "Returns the index of a feature "
     165  "or 0 if it not exists";
     166  Real get.feature.index(Text name)
    167167  ////////////////////////////////////////////////////////////////////////////
    168168  {
    … …  
    195195  Text _.autodoc.member.match.feature.with.value =
    196196  "Returns a column matrix with True in rows where given feature has "
    197   "specified value";
     197  "specified value, numerical or not. If the value is not numeric argument "
     198  "'value.id' must be its name to search it in feature domain";
    198199  VMatrix match.feature.with.value(
    199200    Text feature.name,
    … …  
    201202  ////////////////////////////////////////////////////////////////////////////
    202203  {
    203     Real num = _.feature.index(feature.name);
     204    Real num = get.feature.index(feature.name);
    204205    @Feature f = _.feature[num];
    205206    Real value = If(f::is.numeric(0),
    … …  
    210211
    211212  ////////////////////////////////////////////////////////////////////////////
    212   Text _.autodoc.member.and.match.feature.with.value =
    213   "Returns a column matrix with True in rows where given feature has "
    214   "specified value";
    215   VMatrix and.match.feature.with.value(
    216     Text feature.name,
    217     Anything value.id, //Text value identifier in domain or  Real value
    218     VMatrix match)
    219   ////////////////////////////////////////////////////////////////////////////
    220   {
    221     And(match,select.feature.with.value(feature.name,value.id))
     213  Text _.autodoc.member.match.feature.in.interval =
     214  "Returns a column matrix with True in rows where given numerical feature "
     215  "whose cell is inside the interval defined as: \n"
     216  "  [min,max]: if minIncluded=True  and minIncluded=True\n"
     217  "  (min,max]: if minIncluded=False and minIncluded=True\n"
     218  "  [min,max): if minIncluded=True  and minIncluded=False\n"
     219  "  (min,max): if minIncluded=False and minIncluded=False\n";
     220  VMatrix match.feature.in.interval(
     221    Text feature.name,
     222    Real minIncluded,
     223    Real min,
     224    Real max,
     225    Real maxIncluded)
     226  ////////////////////////////////////////////////////////////////////////////
     227  {
     228    Real num = get.feature.index(feature.name);
     229    @Feature f = _.feature[num];
     230    MatQuery::MatchRowsInInterval(
     231      SubCol(_.data,[[num]]),
     232      minIncluded,
     233      min,
     234      max,
     235      maxIncluded)
     236  };
     237
     238  ////////////////////////////////////////////////////////////////////////////
     239  Text _.autodoc.member.extract.feature =
     240  "Returns a column matrix with all rows with numerical code of a given "
     241  "feature";
     242  VMatrix extract.feature(
     243    Text feature.name,
     244    Set row.indexes) //Text value identifier in domain or  Real value
     245  ////////////////////////////////////////////////////////////////////////////
     246  {
     247    Real col = get.feature.index(feature.name);
     248    SubCol(_.data,[[col]])
     249  };
     250
     251  ////////////////////////////////////////////////////////////////////////////
     252  Text _.autodoc.member.extract.feature.rows =
     253  "Returns a column matrix with selected rows with numerical code of a "
     254  "given feature";
     255  VMatrix extract.feature.rows(
     256    Text feature.name,
     257    Set row.indexes) //Text value identifier in domain or  Real value
     258  ////////////////////////////////////////////////////////////////////////////
     259  {
     260    Real col = get.feature.index(feature.name);
     261    SubRow(SubCol(_.data,[[col]]),row.indexes)
    222262  }
     263
     264
    223265}
    224266
Note: See TracChangeset for help on using the changeset viewer.