|
realroot_doc 0.1.1
|
#include <variables.hpp>
Definition at line 65 of file variables.hpp.
| variables | ( | ) | [inline] |
Definition at line 71 of file variables.hpp.
:_nbvar(0) {}
| variables | ( | const char * | s | ) | [inline] |
Construction the list of variables from a string of the form "a b c ...".
Definition at line 74 of file variables.hpp.
{*this=s;}
| std::string & let | ( | int | i, |
| const std::string & | s | ||
| ) |
Assign the variable of index i to be s.
Definition at line 40 of file variables.cpp.
{
_index_of_var[s]=i+1;
_var_of_index[i+1]=s;
if(i+1>_nbvar) _nbvar=i+1;
return _var_of_index[i+1];
}
| int nbvar | ( | ) | const [inline] |
Definition at line 86 of file variables.hpp.
References variables::_nbvar.
Referenced by ring< C, B, O >::nbvar(), ring< C, Univariate >::nbvar(), ring< C, MonomialTensor >::nbvar(), ring< C, Sparse, O >::nbvar(), and ring< C, Bernstein >::nbvar().
{return _nbvar;}
| variables & operator= | ( | const char * | s | ) |
Assign a set of variables from a string of the form "a b c ...".
Definition at line 48 of file variables.cpp.
| std::string operator[] | ( | int | i | ) |
Return the variable of index i.
Definition at line 11 of file variables.cpp.
References variables::_var_of_index.
{
if(_var_of_index[i+1]!="")
return _var_of_index[i+1];
else
{
int sz=1,m=1;
while(m<i) {m*=10; sz++;}
char str[sz];
sprintf(str,"%d",i);
return std::string("x")+str;
}
}
| int operator[] | ( | const std::string & | s | ) |
Return the index of the variable s.
Definition at line 61 of file variables.cpp.
{
// std::cout <<">> "<<s<<" "<<_nbvar<<" ";
if(s[0]=='x' && s.size()>1 )
{
const char* var=s.data()+1;
// _nbvar= std::max((int)_nbvar,atoi(var)+1);
// std::cout<<":"<<atoi(var)<<std::endl;
return atoi(var);
}
else
{
if(_nbvar==0)
{
_nbvar++;
_index_of_var[s]=_nbvar;
_var_of_index[_nbvar]=s;
return 0;
}
else
{
int i=_index_of_var[s]-1;
if(i<0)
{
while(_var_of_index[_nbvar]!="")
{
_nbvar++;
}
i=_nbvar-1;
// std::cout<<"I "<<i<<std::endl;
_index_of_var[s]=_nbvar;
_var_of_index[_nbvar]=s;
}
return i;
}
}
}
| std::string operator[] | ( | int | i | ) | const |
Return the variable of index i.
Definition at line 25 of file variables.cpp.
References variables::_var_of_index.
{
std::map<int,std::string>::const_iterator pt=_var_of_index.find(i+1);
if(pt!= _var_of_index.end())
return pt->second;
else
{
int sz=1,m=1;
while(m<i) {m*=10; sz++;}
char str[sz];
sprintf(str,"%d",i);
return std::string("x")+str;
}
}
| int size | ( | void | ) | const [inline] |
| std::map<std::string,int> _index_of_var |
Definition at line 68 of file variables.hpp.
| int _nbvar |
Definition at line 67 of file variables.hpp.
Referenced by variables::nbvar(), and variables::size().
| std::map<int,std::string> _var_of_index |
Definition at line 69 of file variables.hpp.
Referenced by variables::operator[]().
Definition at line 89 of file variables.hpp.
Referenced by mmx::sparse::print().