#include <TVec_decl.h>
Inheritance diagram for PLearn::TVec< T >:
Public Types | |
typedef T | value_type |
typedef int | size_type |
typedef T * | iterator |
typedef const T * | const_iterator |
Public Member Functions | |
iterator | begin () const |
iterator | end () const |
TVec (const vector< T > &vec) | |
TVec () | |
TVec (int the_length) | |
TVec (int the_length, const T &init_value) | |
Builds a Vec of specified length with all values initialised with the given value. | |
TVec (const T &start, const T &stop, const T &step) | |
Builds a Vec containing values ranging from start to stop with step e.g., Vec(0,n-1,1) returns a vector of length() n, with 0,1,...n-1. | |
TVec (int the_length, T *the_data) | |
Builds a TVec which data is the_data. | |
TVec (const TVec< T > &other) | |
NOTE: COPY CONSTRUCTOR COPIES THE TVec STRUCTURE BUT NOT THE DATA. | |
const TVec< T > & | operator= (const TVec< T > &other) |
NOTE: operator= COPIES THE TVec STRUCTURE BUT NOT THE DATA (use operator<< to copy data). | |
operator vector () const | |
bool | hasMissing () const |
int | size () const |
int | length () const |
int | capacity () const |
int | offset () const |
PP< Storage< T > > | getStorage () const |
void | compact () |
Makes sure the allocated memory for this vector is exactly length(). | |
operator char * () const | |
used by Hash (VERY DIRTY: TO BE REMOVED [Pascal]) | |
size_t | byteLength () const |
void | resize (int newlength, int extrabytes=0) |
void | write (PStream &out) const |
writes the Vec to the PStream: Note that users should rather use the form out << v; | |
void | read (PStream &in) |
reads the Vec from the PStream: Note that users should rather use the form in >> v; | |
void | save (const string &filename) const |
void | load (const string &filename) |
TVec< T > | subVec (int newstart, int newlength) const |
Returns a sub-TVector. | |
void | makeDeepCopyFromShallowCopy (map< const void *, void * > &copies) |
TVec< T > | deepCopy (map< const void *, void * > &copies) const |
TVec< T > | subVec (Range r) |
void | concat (const TVec< T > &input1, const TVec< T > &input2) |
Returns a TVector made up of the two (or more) input TVec. | |
void | concat (const TVec< T > &input1, const TVec< T > &input2, const TVec< T > &input3) |
void | concat (const TVec< T > &input1, const TVec< T > &input2, const TVec< T > &input3, const TVec< T > &input4) |
TMat< T > | toMat (int newlength, int newwidth) const |
The returned TMat will view the same data. | |
TVec< T > | copy () const |
returns a newly created copy of this TVec | |
void | copyFrom (const T *x, int n) const |
copy from a C TVector starting at x of length() n | |
void | copyTo (T *x) const |
copy to a C TVec starting at x | |
void | makeSharedValue (T *x, int n) |
bool | isNull () const |
bool | isNotNull () const |
bool | isEmpty () const |
bool | isNotEmpty () const |
bool | operator! () const |
To allow if(!v) statements. | |
TVec< T > * | operator-> () |
void | fill (const T &value) const |
Fills the vector with the given value; no-op if vector is null. | |
void | fill (const T &startval, const T &step) |
Fills the vector, putting startval in its first element and increments of step in subsequent elements. | |
void | operator= (const T &f) const |
same as fill(f) | |
void | clear () const |
void | insert (int position, T value) |
inserts element at position (actually between values at position-1 and posiion). Length is increased by 1. | |
void | remove (int position) |
removes element at position, Length is decreased by 1 | |
int | findSorted (T value) |
void | insertSorted (T value, bool uniq) |
void | removeSorted (T value) |
void | append (const T &newval) |
void | append (const vector< T > &newvec) |
for compatibility with Array | |
void | appendIfNotThereAlready (const T &newval) |
for compatibility with Array | |
void | push_back (const T &newval) |
stl compatibility | |
void | pop_back () |
void | push (const T &newval) |
stack interface compatibility | |
T | pop () |
T & | top () const |
void | append (const TVec< T > &values) |
T & | operator[] (int i) const |
T & | operator[] (unsigned int i) const |
T & | lastElement () const |
T & | firstElement () const |
T & | front () const |
T & | back () const |
T & | first () const |
T & | last () const |
template<class I> void | operator() (const TVec< I > &indices, TVec< T > &destination) const |
Deprecated: use the select function instead. | |
template<class I> TVec< T > | operator() (const TVec< I > &indices) const |
T * | data () const |
Returns a pointer to the beginning of the TVector data. | |
void | swap () |
swaps first and last element, second and second last, etc... (mirror symmetry). | |
TVec< bool > | operator== (const T &value) const |
return a vector with 1's when (*this)[i]==value for all i, 0 otherwise | |
bool | operator== (const TVec< T > &value) const |
return true if (*this)[i]==value[i] for all i, 0 otherwise | |
bool | operator!= (const TVec< T > &value) const |
bool | contains (const T &element) const |
return true if element is in the TVec and false otherwise. | |
TVec< T > | findIndices (const T &element) |
return the set of indices whose corresponding values are "element". | |
TVec< T > | findIndices (const TVec< T > &elements) |
int | find (const T &element, int start=0) const |
Returns the position of the first occurence of element in the vector or -1 if it never occurs. | |
TVec< T > | find (TVec< T > elements) |
void | print (ostream &out=cout) const |
the data is printed on a single row, no newline | |
void | println (ostream &out=cout) const |
same with newline | |
void | printcol (ostream &out=cout) const |
printed as a column | |
void | print (ostream &out, const string &separator) const |
each value is printed with the given separator string between them | |
void | input (istream &in=cin) const |
void | debugPrint () |
void | operator<< (const string &datastring) const |
Protected Attributes | |
int | length_ |
int | offset_ |
PP< Storage< T > > | storage |
Friends | |
class | TMat< T > |
|
Definition at line 93 of file TVec_decl.h. |
|
|
Definition at line 91 of file TVec_decl.h. |
|
Definition at line 90 of file TVec_decl.h. |
|
Definition at line 107 of file TVec_decl.h. |
|
Definition at line 115 of file TVec_decl.h. |
|
Definition at line 119 of file TVec_decl.h. |
|
Builds a Vec of specified length with all values initialised with the given value.
Definition at line 125 of file TVec_decl.h. |
|
Builds a Vec containing values ranging from start to stop with step e.g., Vec(0,n-1,1) returns a vector of length() n, with 0,1,...n-1. creates range (start, start+step, ..., stop) Definition at line 69 of file TMat_impl.h. References PLearn::TVec< T >::begin(), PLearn::TVec< T >::end(), PLearn::TVec< T >::iterator, resize(), and val. |
|
Builds a TVec which data is the_data.
Definition at line 136 of file TVec_decl.h. |
|
NOTE: COPY CONSTRUCTOR COPIES THE TVec STRUCTURE BUT NOT THE DATA.
Definition at line 142 of file TVec_decl.h. |
|
Definition at line 575 of file TVec_decl.h. |
|
for compatibility with Array
Definition at line 534 of file TVec_decl.h. |
|
|
for compatibility with Array
Definition at line 546 of file TVec_decl.h. |
|
Definition at line 614 of file TVec_decl.h. Referenced by PLearn::StatsCollector::getBinMapping(). |
|
|
|
Definition at line 181 of file TVec_decl.h. Referenced by PLearn::TVec< pair< real, real > >::resize(). |
|
|
Makes sure the allocated memory for this vector is exactly length().
Definition at line 187 of file TVec_decl.h. |
|
Definition at line 360 of file TVec_decl.h. |
|
Definition at line 349 of file TVec_decl.h. |
|
Returns a TVector made up of the two (or more) input TVec.
Definition at line 340 of file TVec_decl.h. |
|
return true if element is in the TVec and false otherwise. < get start of data Definition at line 684 of file TVec_decl.h. Referenced by PLearn::FinancePreprocVMatrix::getNewRow(), and PLearn::grep(). |
|
returns a newly created copy of this TVec
Definition at line 377 of file TVec_decl.h. Referenced by PLearn::CompactVMatrix::append(), PLearn::TVec< pair< real, real > >::compact(), PLearn::CompactVMatrix::CompactVMatrix(), PLearn::grep(), PLearn::Gnuplot::plotcdf(), PLearn::Gnuplot::plotdensity(), and PLearn::Function::verifyGradient(). |
|
copy from a C TVector starting at x of length() n < get data start Definition at line 385 of file TVec_decl.h. Referenced by PLearn::RowBufferedVMatrix::getRow(), PLearn::MemoryVMatrix::getRow(), PLearn::RowBufferedVMatrix::getSubRow(), and PLearn::MemoryVMatrix::getSubRow(). |
|
copy to a C TVec starting at x
Definition at line 397 of file TVec_decl.h. Referenced by PLearn::MemoryVMatrix::putRow(), and PLearn::MemoryVMatrix::putSubRow(). |
|
|
Definition at line 763 of file TVec_decl.h. |
|
Notice that deepCopy of a Vec returns a Vec rather than a Vec*. The reason for this being that a Vec is already some kind of "smart pointer" to an underlying Storage Definition at line 70 of file TVec_impl.h. References PLearn::TVec< T >::makeDeepCopyFromShallowCopy(). Referenced by PLearn::deepCopy(). |
|
|
Fills the vector, putting startval in its first element and increments of step in subsequent elements.
Definition at line 459 of file TVec_decl.h. |
|
|
Definition at line 739 of file TVec_decl.h. |
|
Returns the position of the first occurence of element in the vector or -1 if it never occurs.
Definition at line 729 of file TVec_decl.h. |
|
Definition at line 710 of file TVec_decl.h. |
|
return the set of indices whose corresponding values are "element". TODO Olivier: hmm, looks like it should return TVec<int>, no ? (same for other find methods) Definition at line 697 of file TVec_decl.h. |
|
Definition at line 501 of file TVec_decl.h. |
|
Definition at line 617 of file TVec_decl.h. Referenced by PLearn::Grapher::computeAutoGridrange(), PLearn::computeNearestNeighbors(), PLearn::RealMapping::getCutPoints(), and PLearn::FractionSplitter::getSplit(). |
|
Definition at line 610 of file TVec_decl.h. Referenced by PLearn::TVec< pair< real, real > >::first(), and PLearn::TVec< pair< real, real > >::front(). |
|
Definition at line 613 of file TVec_decl.h. |
|
Definition at line 184 of file TVec_decl.h. Referenced by PLearn::TVec< pair< real, real > >::write(). |
|
Definition at line 169 of file TVec_decl.h. Referenced by PLearn::filter(), PLearn::SDBVMatrix::getRow(), PLearn::MovingAverage::test(), PLearn::EmbeddedSequentialLearner::test(), and PLearn::MovingAverage::train(). |
|
Definition at line 104 of file TMat_impl.h. References PLearn::TVec< T >::data(), PLearn::TVec< T >::length(), and PLERROR. Referenced by PLearn::operator>>(). |
|
inserts element at position (actually between values at position-1 and posiion). Length is increased by 1.
Definition at line 475 of file TVec_decl.h. |
|
Definition at line 512 of file TVec_decl.h. Referenced by PLearn::RemoveRowsVMatrix::remove(). |
|
|
Definition at line 430 of file TVec_decl.h. Referenced by PLearn::PDistribution::finishConditionalBuild(), and PLearn::matlabSave(). |
|
Definition at line 424 of file TVec_decl.h. |
|
Definition at line 421 of file TVec_decl.h. Referenced by PLearn::TVec< pair< real, real > >::clear(), PLearn::TVec< pair< real, real > >::operator char *(), and PLearn::Array< char * >::operator char *(). |
|
Definition at line 618 of file TVec_decl.h. |
|
|
|
Definition at line 308 of file TVec_decl.h. |
|
|
make the storage point to this address and copy current value to it (i.e. without changing current contents) < get data start Definition at line 408 of file TVec_decl.h. |
|
Definition at line 182 of file TVec_decl.h. Referenced by PLearn::TVec< pair< real, real > >::write(). |
|
used by Hash (VERY DIRTY: TO BE REMOVED [Pascal])
Reimplemented in PLearn::Array< T >, PLearn::Array< real >, PLearn::Array< ofstream * >, PLearn::Array< RGBImage * >, PLearn::Array< CostFunc >, PLearn::Array< VMFieldStat >, PLearn::Array< Measurer * >, PLearn::Array< TMat< int > >, PLearn::Array< Array< string > >, PLearn::Array< PSDBVMFieldDiscrete >, PLearn::Array< StatsIt >, PLearn::Array< PP< HyperOptimizer > >, PLearn::Array< VMField >, PLearn::Array< Mat >, PLearn::Array< string >, PLearn::Array< RVInstance >, PLearn::Array< Vec >, PLearn::Array< VMat >, PLearn::Array< Var >, PLearn::Array< RandomVar >, and PLearn::Array< char * >. Definition at line 198 of file TVec_decl.h. |
|
Definition at line 156 of file TVec_decl.h. |
|
To allow if(!v) statements. This method is commented out because it is much too dangerous: it allows a TVec to be converted into an int, which can cause some very weird bugs that the compiler would have caught otherwise. Reimplemented in PLearn::Array< T >, PLearn::Array< real >, PLearn::Array< ofstream * >, PLearn::Array< RGBImage * >, PLearn::Array< CostFunc >, PLearn::Array< VMFieldStat >, PLearn::Array< Measurer * >, PLearn::Array< TMat< int > >, PLearn::Array< Array< string > >, PLearn::Array< PSDBVMFieldDiscrete >, PLearn::Array< StatsIt >, PLearn::Array< PP< HyperOptimizer > >, PLearn::Array< VMField >, PLearn::Array< Mat >, PLearn::Array< string >, PLearn::Array< RVInstance >, PLearn::Array< Vec >, PLearn::Array< VMat >, PLearn::Array< Var >, PLearn::Array< RandomVar >, and PLearn::Array< char * >. Definition at line 443 of file TVec_decl.h. |
|
Definition at line 681 of file TVec_decl.h. |
|
select the elements of the source (this) as specified by the TVector of indices (between 0 and this->length()-1) into the returned TVector (which will have the same length() as the indices TVector). Definition at line 632 of file TVec_decl.h. |
|
Deprecated: use the select function instead.
Definition at line 623 of file TVec_decl.h. |
|
Definition at line 447 of file TVec_decl.h. |
|
Definition at line 766 of file TVec_decl.h. |
|
same as fill(f)
Definition at line 468 of file TVec_decl.h. |
|
NOTE: operator= COPIES THE TVec STRUCTURE BUT NOT THE DATA (use operator<< to copy data).
Reimplemented in PLearn::Array< T >, PLearn::Array< real >, PLearn::Array< ofstream * >, PLearn::Array< RGBImage * >, PLearn::Array< CostFunc >, PLearn::Array< VMFieldStat >, PLearn::Array< Measurer * >, PLearn::Array< TMat< int > >, PLearn::Array< Array< string > >, PLearn::Array< PSDBVMFieldDiscrete >, PLearn::Array< StatsIt >, PLearn::Array< PP< HyperOptimizer > >, PLearn::Array< VMField >, PLearn::Array< Mat >, PLearn::Array< string >, PLearn::Array< RVInstance >, PLearn::Array< Vec >, PLearn::Array< VMat >, PLearn::Array< Var >, PLearn::Array< RandomVar >, and PLearn::Array< char * >. Definition at line 148 of file TVec_decl.h. |
|
return true if (*this)[i]==value[i] for all i, 0 otherwise
Definition at line 671 of file TVec_decl.h. |
|
return a vector with 1's when (*this)[i]==value for all i, 0 otherwise
Definition at line 659 of file TVec_decl.h. |
|
Definition at line 597 of file TVec_decl.h. |
|
Reimplemented in PLearn::RVArray, and PLearn::VarArray. Definition at line 587 of file TVec_decl.h. |
|
Definition at line 569 of file TVec_decl.h. Referenced by PLearn::VMatLanguage::run(). |
|
Definition at line 558 of file TVec_decl.h. Referenced by PLearn::StatsCollector::getBinMapping(), and PLearn::TVec< pair< real, real > >::pop(). |
|
each value is printed with the given separator string between them
Definition at line 129 of file TMat_impl.h. References PLearn::TVec< T >::data(), and PLearn::TVec< T >::length(). |
|
the data is printed on a single row, no newline
Reimplemented in PLearn::Array< T >, PLearn::Array< real >, PLearn::Array< ofstream * >, PLearn::Array< RGBImage * >, PLearn::Array< CostFunc >, PLearn::Array< VMFieldStat >, PLearn::Array< Measurer * >, PLearn::Array< TMat< int > >, PLearn::Array< Array< string > >, PLearn::Array< PSDBVMFieldDiscrete >, PLearn::Array< StatsIt >, PLearn::Array< PP< HyperOptimizer > >, PLearn::Array< VMField >, PLearn::Array< Mat >, PLearn::Array< string >, PLearn::Array< RVInstance >, PLearn::Array< Vec >, PLearn::Array< VMat >, PLearn::Array< Var >, PLearn::Array< RandomVar >, and PLearn::Array< char * >. Definition at line 116 of file TMat_impl.h. References PLearn::TVec< T >::data(), PLearn::TVec< T >::length(), and PLearn::TVec< T >::storage. Referenced by PLearn::operator<<(). |
|
printed as a column
Definition at line 140 of file TMat_impl.h. References PLearn::TVec< T >::data(), and PLearn::TVec< T >::length(). |
|
same with newline
Definition at line 756 of file TVec_decl.h. Referenced by PLearn::Experiment::run(). |
|
stack interface compatibility
Definition at line 566 of file TVec_decl.h. Referenced by PLearn::VMatLanguage::run(). |
|
stl compatibility
Definition at line 555 of file TVec_decl.h. Referenced by PLearn::RealMapping::buildOrderedMapping(), PLearn::getList(), PLearn::DatedJoinVMatrix::getNewRow(), PLearn::WordNetOntology::getSecondLevelSensesForWord(), PLearn::WordNetOntology::getThirdLevelSensesForWord(), and PLearn::AdaBoost::train(). |
|
reads the Vec from the PStream: Note that users should rather use the form in >> v;
Definition at line 258 of file TVec_decl.h. Referenced by PLearn::operator>>(). |
|
removes element at position, Length is decreased by 1
Definition at line 489 of file TVec_decl.h. |
|
Definition at line 519 of file TVec_decl.h. Referenced by PLearn::RemoveRowsVMatrix::unremove(). |
|
|
Definition at line 307 of file TVec_decl.h. |
|
|
Definition at line 337 of file TVec_decl.h. |
|
|
swaps first and last element, second and second last, etc... (mirror symmetry).
Definition at line 650 of file TVec_decl.h. Referenced by PLearn::eigen_SymmMat_decreasing(), PLearn::eigenVecOfSymmMat(), and PLearn::generalizedEigenVecOfSymmMat(). |
|
|
Definition at line 572 of file TVec_decl.h. Referenced by PLearn::VMatLanguage::run(). |
|
writes the Vec to the PStream: Note that users should rather use the form out << v;
Definition at line 237 of file TVec_decl.h. |
|
Definition at line 74 of file TVec_decl.h. |
|
The length of the data Definition at line 84 of file TVec_decl.h. Referenced by PLearn::TMat< pair< real, real > >::operator()(), PLearn::TVec< pair< real, real > >::operator=(), PLearn::TVec< pair< real, real > >::read(), PLearn::TVec< pair< real, real > >::subVec(), and PLearn::TMat< T >::toVec(). |
|
the displacement to do with respect to storage->data Definition at line 85 of file TVec_decl.h. Referenced by PLearn::Variable::makeSharedGradient(), PLearn::VarArray::makeSharedGradient(), PLearn::Variable::makeSharedRValue(), PLearn::VarArray::makeSharedRValue(), PLearn::Variable::makeSharedValue(), PLearn::TMat< pair< real, real > >::operator()(), PLearn::TVec< pair< real, real > >::operator=(), PLearn::TVec< pair< real, real > >::read(), PLearn::TVec< pair< real, real > >::subVec(), PLearn::TVec< T >::toMat(), and PLearn::TMat< T >::toVec(). |
|