API  4.4
For C++ developers
OpenSim::DataTable_< ETX, ETY > Class Template Reference

DataTable_ is an in-memory storage container for data with support for holding metadata (using the base class AbstractDataTable). More...

+ Inheritance diagram for OpenSim::DataTable_< ETX, ETY >:

Public Member Functions

 DataTable_ ()=default
 
 DataTable_ (const DataTable_ &)=default
 
 DataTable_ (DataTable_ &&)=default
 
DataTable_operator= (const DataTable_ &)=default
 
DataTable_operator= (DataTable_ &&)=default
 
 ~DataTable_ ()=default
 
std::shared_ptr< AbstractDataTableclone () const override
 
 DataTable_ (const std::string &filename, const std::string &tablename)
 Construct DataTable_ from a file. More...
 
template<typename ThatETY >
 DataTable_ (const DataTable_< double, ThatETY > &that, const std::vector< std::string > &suffixes)
 Construct DataTable_<double, double> from DataTable_<double, ThatETY> where ThatETY can be SimTK::Vec<X>. More...
 
 DataTable_ (const DataTable_< double, double > &that, const std::vector< std::string > &suffixes)
 Construct this DataTable from a DataTable_<double, double>. More...
 
template<typename ThatETY >
 DataTable_ (const DataTable_< double, ThatETY > &that)
 Construct DataTable_<double, double> from DataTable_<double, ThatETY> where ThatETY can be SimTK::Vec<X>. More...
 
template<typename ThatETY >
DataTable_operator= (const DataTable_< double, ThatETY > &that)
 Copy assign a DataTable_<double, double> from DataTable_<double, ThatETY> where ThatETY can be SimTK::Vec<X>. More...
 
DataTable_< double, double > flatten () const
 Flatten the columns of this table to create a DataTable_<double, double>. More...
 
DataTable_< double, double > flatten (const std::vector< std::string > &suffixes) const
 Flatten the columns of this table to create a DataTable_<double, double>. More...
 
template<typename ThatETY >
DataTable_< double, ThatETY > pack () const
 Pack the columns of this table to create a DataTable_<double, ThatETY>, where 'ThatETY' is the template parameter which can be SimTK::Vec3, SimTK::UnitVec3, SimTK::Quaternion, SimTK::SpatialVec and so on. More...
 
template<typename ThatETY >
DataTable_< double, ThatETY > pack (const std::vector< std::string > &suffixes) const
 Pack the columns of this table to create a DataTable_<double, ThatETY>, where 'ThatETY' is the template parameter which can be SimTK::Vec3, SimTK::UnitVec3, SimTK::Quaternion, SimTK::SpatialVec and so on. More...
 
unsigned numComponentsPerElement () const override
 Retrieve the number of components each element (of type ETY) of the table is made of. More...
 
std::string toString (std::vector< int > rows={}, std::vector< std::string > columnLabels={}, const bool withMetaData=true, unsigned splitSize=25, unsigned maxWidth=80, unsigned precision=4) const
 Get a string representation of the table, including the key-value pairs in the table metadata. More...
 
Row accessors/mutators.

Following get/upd functions operate on matrix and not the independent column.

The function appendRow() is pretty flexible and it is possible to append a row with any sequence of elements. Following are some examples:

// Easiest way to append a row is to provide the list of elements
// directly to appendRow.
// For a table with elements of type double, this could look like below.
table.appendRow(0.1, // Independent column.
{0.3, 0.4, 0.5, 0.6}); // 4 elements of type double.
// For a table with elements of type SimTK::Vec3, this could like below.
table.appendRow(0.1, // Independent column.
{{0.31, 0.32, 0.33},
{0.41, 0.42, 0.43},
{0.51, 0.52, 0.53},
{0.61, 0.62, 0.63}}); // 4 elements of SimTK::Vec3.
// It is possible to append a sequence container like std::vector or
// std::list by providing it directly to appendRow.
// For a table with elements of type double, this could look like below.
std::vector<double> row{0.3, 0.4, 0.5, 0.6};
table.appendRow(0.1, row);
// For a table with elements of type SimTK::Vec3, this could look like
// below.
std::vector<SimTK::Vec3> row{{0.31, 0.32, 0.33},
{0.41, 0.42, 0.43},
{0.51, 0.52, 0.53}, // 4 elements of
{0.61, 0.62, 0.63}}); // SimTK::Vec3.
table.appendRow(0.1, row);
// A SimTK::RowVector can be provided to appendRow as well.
// For a table with elements of type double, this could look like below.
SimTK::RowVector row{0.3, 0.4, 0.5, 0.6};
table.appendRow(0.1, row);
// For a table with elements of type SimTK::Vec3, this could look like
// below.
SimTK::RowVector_<SimTK::Vec3> row{{0.31, 0.32, 0.33},
{0.41, 0.42, 0.43},
{0.51, 0.52, 0.53}, // 4 elements of
{0.61, 0.62, 0.63}}); // SimTK::Vec3.
table.appendRow(0.1, row);
// It is possible to be use a pair of iterators to append a row as well.
// This could arise in situations where you might want to append a row
// using a subset of elements in a sequence.
// For a table with elements of type double, this could look like below.
std::vector<double> row{0.3, 0.4, 0.5, 0.6, 0.7, 0.8};
table.appendRow(0.1, // Independent column.
row.begin() + 1, // Start from second element (0.4).
row.end() - 1); // End at last but one (0.7).
// For a table with elements of type SimTK::Vec3, this could look like
// below.
std::vector<SimTK::Vec3> row{{0.31, 0.32, 0.33},
{0.41, 0.42, 0.43},
{0.51, 0.52, 0.53},
{0.61, 0.62, 0.63},
{0.71, 0.72, 0.73}, // 6 elements of
{0.81, 0.82, 0.83}}); // SimTK::Vec3.
table.appendRow(0.1, // Independent column.
row.begin() + 1, // Start from second element.
row.end() - 1); // End at last but one.
template<typename Container >
void appendRow (const ETX &indRow, const Container &container)
 Append row to the DataTable_. More...
 
void appendRow (const ETX &indRow, const std::initializer_list< ETY > &container)
 Append row to the DataTable_. More...
 
template<typename RowIter >
void appendRow (const ETX &indRow, RowIter begin, RowIter end)
 Append row to the DataTable_. More...
 
void appendRow (const ETX &indRow, const RowVector &depRow)
 Append row to the DataTable_. More...
 
void appendRow (const ETX &indRow, const RowVectorView &depRow)
 Append row to the DataTable_. More...
 
const RowVectorView getRowAtIndex (size_t index) const
 Get row at index. More...
 
const RowVectorView getRow (const ETX &ind) const
 Get row corresponding to the given entry in the independent column. More...
 
RowVectorView updRowAtIndex (size_t index)
 Update row at index. More...
 
RowVectorView updRow (const ETX &ind)
 Update row corresponding to the given entry in the independent column. More...
 
void setRowAtIndex (size_t index, const RowVectorView &depRow)
 Set row at index. More...
 
void setRowAtIndex (size_t index, const RowVector &depRow)
 Set row at index. More...
 
void setRow (const ETX &ind, const RowVectorView &depRow)
 Set row corresponding to the given entry in the independent column. More...
 
void setRow (const ETX &ind, const RowVector &depRow)
 Set row corresponding to the given entry in the independent column. More...
 
void removeRowAtIndex (size_t index)
 Remove row at index. More...
 
void removeRow (const ETX &ind)
 Remove row corresponding to the given entry in the independent column. More...
 
Dependent and Independent column accessors/mutators.
const std::vector< ETX > & getIndependentColumn () const
 Get independent column. More...
 
template<typename Container >
void appendColumn (const std::string &columnLabel, const Container &container)
 Append column to the DataTable_ using a sequence container. More...
 
void appendColumn (const std::string &columnLabel, const std::initializer_list< ETY > &container)
 Append column to the DataTable_ using an initializer list. More...
 
template<typename ColIter >
void appendColumn (const std::string &columnLabel, ColIter begin, ColIter end)
 Append column to the DataTable_ using an iterator pair. More...
 
void appendColumn (const std::string &columnLabel, const Vector &depCol)
 Append column to the DataTable_ using a SimTK::Vector. More...
 
void appendColumn (const std::string &columnLabel, const VectorView &depCol)
 Append column to the DataTable_ using a SimTK::VectorView. More...
 
void removeColumnAtIndex (size_t index)
 Remove column corresponding to the given column index. More...
 
void removeColumn (const std::string &columnLabel)
 Remove column corresponding to the given dependent column label. More...
 
VectorView getDependentColumnAtIndex (size_t index) const
 Get dependent column at index. More...
 
VectorView getDependentColumn (const std::string &columnLabel) const
 Get dependent Column which has the given column label. More...
 
VectorView updDependentColumnAtIndex (size_t index)
 Update dependent column at index. More...
 
VectorView updDependentColumn (const std::string &columnLabel)
 Update dependent Column which has the given column label. More...
 
void setIndependentValueAtIndex (size_t rowIndex, const ETX &value)
 Set value of the independent column at index. More...
 
Matrix accessors/mutators.

Following functions operate on the matrix not including the independent column.

const MatrixViewgetMatrix () const
 Get a read-only view to the underlying matrix. More...
 
MatrixView getMatrixBlock (size_t rowStart, size_t columnStart, size_t numRows, size_t numColumns) const
 Get a read-only view of a block of the underlying matrix. More...
 
MatrixViewupdMatrix ()
 Get a writable view to the underlying matrix. More...
 
MatrixView updMatrixBlock (size_t rowStart, size_t columnStart, size_t numRows, size_t numColumns)
 Get a writable view of a block of the underlying matrix. More...
 
- Public Member Functions inherited from OpenSim::AbstractDataTable
 AbstractDataTable ()=default
 
 AbstractDataTable (const AbstractDataTable &)=default
 
 AbstractDataTable (AbstractDataTable &&)=default
 
AbstractDataTableoperator= (const AbstractDataTable &)=default
 
AbstractDataTableoperator= (AbstractDataTable &&)=default
 
virtual ~AbstractDataTable ()=default
 
size_t getNumRows () const
 Get number of rows. More...
 
size_t getNumColumns () const
 Get number of dependent columns. More...
 
bool hasColumn (const size_t columnIndex) const
 Check if the table has a column with the given index. More...
 
template<typename Value >
void addTableMetaData (const std::string &key, const Value &value)
 Add key-value pair to the table metadata. More...
 
bool hasTableMetaDataKey (const std::string &key) const
 Whether or not table metadata for the given key exists. More...
 
template<typename Value >
Value getTableMetaData (const std::string &key) const
 Get table metadata for a given key. More...
 
std::string getTableMetaDataAsString (const std::string &key) const
 Get table metadata for a given key as a string. More...
 
void removeTableMetaDataKey (const std::string &key)
 Remove key-value pair associated with the given key from table metadata. More...
 
std::vector< std::string > getTableMetaDataKeys () const
 Get table metadata keys. More...
 
const TableMetaDatagetTableMetaData () const
 Get metadata associated with the table. More...
 
TableMetaDataupdTableMetaData ()
 Update metadata associated with the table. More...
 
const IndependentMetaDatagetIndependentMetaData () const
 Get metadata associated with the independent column. More...
 
void setIndependentMetaData (const IndependentMetaData &independentMetaData)
 Set metadata associated with the independent column. More...
 
const DependentsMetaDatagetDependentsMetaData () const
 Get metadata associated with the dependent columns. More...
 
void setDependentsMetaData (const DependentsMetaData &dependentsMetaData)
 Set metadata associated with the dependent columns. More...
 
void removeDependentsMetaDataForKey (const std::string &key)
 Remove key-value pair associated with the given key from dependents metadata. More...
 
bool hasColumnLabels () const
 Does the table have non-zero number of column labels. More...
 
std::vector< std::string > getColumnLabels () const
 Get column labels. More...
 
const std::string & getColumnLabel (const size_t columnIndex) const
 Get column label of a given column. More...
 
template<typename InputIt >
void setColumnLabels (InputIt first, InputIt last)
 Set column labels using a pair of iterators. More...
 
template<typename Container >
void setColumnLabels (const Container &columnLabels)
 Set column labels using a sequence container. More...
 
void setColumnLabels (const std::initializer_list< std::string > &columnLabels)
 Set column labels using a std::initializer_list. More...
 
void setColumnLabel (const size_t columnIndex, const std::string &columnLabel)
 Set the label for a column. More...
 
size_t getColumnIndex (const std::string &columnLabel) const
 Get index of a column label. More...
 
bool hasColumn (const std::string &columnLabel) const
 Check if the table has a column with the given label. More...
 

Public Types

typedef SimTK::RowVector_< ETY > RowVector
 Type of each row of matrix holding dependent data. More...
 
typedef SimTK::RowVectorView_< ETY > RowVectorView
 (Read only view) Type of each row of matrix. More...
 
typedef SimTK::Vector_< ETY > Vector
 Type of each column of matrix holding dependent data. More...
 
typedef SimTK::VectorView_< ETY > VectorView
 Type of each column of matrix holding dependent data. More...
 
typedef SimTK::Matrix_< ETY > Matrix
 Type of the matrix holding the dependent data. More...
 
typedef SimTK::MatrixView_< ETY > MatrixView
 (Read only view) Type of the matrix holding the dependent data. More...
 
- Public Types inherited from OpenSim::AbstractDataTable
typedef ValueArrayDictionary TableMetaData
 
typedef ValueArrayDictionary DependentsMetaData
 
typedef ValueArrayDictionary IndependentMetaData
 

Protected Member Functions

 DataTable_ (const std::vector< ETX > &indVec, const SimTK::Matrix_< ETY > &depData, const std::vector< std::string > &labels)
 Convenience constructor to efficiently populate a DataTable from known data. More...
 
 DataTable_ (const std::vector< ETX > &indVec)
 Construct a table with only the independent column and 0 dependent columns. More...
 
std::string toString_impl (std::vector< int > rows={}, std::vector< int > cols={}, const bool withMetaData=true, unsigned splitSize=25, unsigned maxWidth=80, unsigned precision=4) const
 
bool isEmpty () const
 Determine whether table is empty. More...
 
bool isRowIndexOutOfRange (size_t index) const
 Check if row index is out of range. More...
 
bool isColumnIndexOutOfRange (size_t index) const
 Check if column index is out of range. More...
 
size_t implementGetNumRows () const override
 Get number of rows. More...
 
size_t implementGetNumColumns () const override
 Get number of columns. More...
 
void validateIndependentMetaData () const override
 Validate metadata for independent column. More...
 
void validateDependentsMetaData () const override
 Validate metadata for dependent columns. More...
 
virtual void validateRow (size_t rowIndex, const ETX &, const RowVector &) const
 Derived classes optionally can implement this function to validate append/update operations. More...
 
- Protected Member Functions inherited from OpenSim::AbstractDataTable
void appendColumnLabel (const std::string &columnLabel)
 Append column-label. More...
 

Static Protected Member Functions

template<int N, typename Iter >
static void splitAndAssignElement (Iter begin, Iter end, const SimTK::Vec< N > &elem)
 
template<int M, int N, typename Iter >
static void splitAndAssignElement (Iter begin, Iter end, const SimTK::Vec< M, SimTK::Vec< N >> &elem)
 
template<int M, int N, typename Iter >
static void splitAndAssignElement (Iter begin, Iter end, const SimTK::Mat< M, N > &elem)
 
template<typename Iter >
static void splitAndAssignElement (Iter begin, Iter end,...)
 
template<typename ELT >
static SimTK::RowVector_< double > splitElement (const ELT &elt)
 
static SimTK::RowVector_< double > splitElement (const double &elt)
 
template<typename Iter >
static void makeElement_helper (double &elem, Iter begin, Iter end)
 
template<int N, typename Iter >
static void makeElement_helper (SimTK::Vec< N > &elem, Iter begin, Iter end)
 
template<int M, int N, typename Iter >
static void makeElement_helper (SimTK::Vec< M, SimTK::Vec< N >> &elem, Iter begin, Iter end)
 
template<int M, int N, typename Iter >
static void makeElement_helper (SimTK::Mat< M, N > &elem, Iter begin, Iter end)
 
template<typename Iter >
static ETY makeElement (Iter begin, Iter end)
 
static constexpr unsigned numComponentsPerElement_impl (double)
 
template<int M>
static constexpr unsigned numComponentsPerElement_impl (SimTK::Vec< M >)
 
template<int M, int N>
static constexpr unsigned numComponentsPerElement_impl (SimTK::Mat< M, N >)
 
template<int M, int N>
static constexpr unsigned numComponentsPerElement_impl (SimTK::Vec< M, SimTK::Vec< N >>)
 

Protected Attributes

std::vector< ETX > _indData
 
SimTK::Matrix_< ETY > _depData
 
- Protected Attributes inherited from OpenSim::AbstractDataTable
TableMetaData _tableMetaData
 
DependentsMetaData _dependentsMetaData
 
IndependentMetaData _independentMetaData
 

Detailed Description

template<typename ETX = double, typename ETY = SimTK::Real>
class OpenSim::DataTable_< ETX, ETY >

DataTable_ is an in-memory storage container for data with support for holding metadata (using the base class AbstractDataTable).

Data contains an independent column and a set of dependent columns. The type of the independent column can be configured using ETX (template param). The type of the dependent columns, which together form a matrix, can be configured using ETY (template param). Independent and dependent columns can contain metadata. DataTable_ as a whole can contain metadata.

Template Parameters
ETXType of each element of the column holding independent data.
ETYType of each element of the underlying matrix holding dependent data.

Member Typedef Documentation

◆ Matrix

template<typename ETX = double, typename ETY = SimTK::Real>
typedef SimTK::Matrix_<ETY> OpenSim::DataTable_< ETX, ETY >::Matrix

Type of the matrix holding the dependent data.

◆ MatrixView

template<typename ETX = double, typename ETY = SimTK::Real>
typedef SimTK::MatrixView_<ETY> OpenSim::DataTable_< ETX, ETY >::MatrixView

(Read only view) Type of the matrix holding the dependent data.

◆ RowVector

template<typename ETX = double, typename ETY = SimTK::Real>
typedef SimTK::RowVector_<ETY> OpenSim::DataTable_< ETX, ETY >::RowVector

Type of each row of matrix holding dependent data.

◆ RowVectorView

template<typename ETX = double, typename ETY = SimTK::Real>
typedef SimTK::RowVectorView_<ETY> OpenSim::DataTable_< ETX, ETY >::RowVectorView

(Read only view) Type of each row of matrix.

◆ Vector

template<typename ETX = double, typename ETY = SimTK::Real>
typedef SimTK::Vector_<ETY> OpenSim::DataTable_< ETX, ETY >::Vector

Type of each column of matrix holding dependent data.

◆ VectorView

template<typename ETX = double, typename ETY = SimTK::Real>
typedef SimTK::VectorView_<ETY> OpenSim::DataTable_< ETX, ETY >::VectorView

Type of each column of matrix holding dependent data.

Constructor & Destructor Documentation

◆ DataTable_() [1/9]

template<typename ETX = double, typename ETY = SimTK::Real>
OpenSim::DataTable_< ETX, ETY >::DataTable_ ( )
default

◆ DataTable_() [2/9]

template<typename ETX = double, typename ETY = SimTK::Real>
OpenSim::DataTable_< ETX, ETY >::DataTable_ ( const DataTable_< ETX, ETY > &  )
default

◆ DataTable_() [3/9]

template<typename ETX = double, typename ETY = SimTK::Real>
OpenSim::DataTable_< ETX, ETY >::DataTable_ ( DataTable_< ETX, ETY > &&  )
default

◆ ~DataTable_()

template<typename ETX = double, typename ETY = SimTK::Real>
OpenSim::DataTable_< ETX, ETY >::~DataTable_ ( )
default

◆ DataTable_() [4/9]

template<typename ETX = double, typename ETY = SimTK::Real>
OpenSim::DataTable_< ETX, ETY >::DataTable_ ( const std::string &  filename,
const std::string &  tablename 
)
inline

Construct DataTable_ from a file.

Parameters
filenameName of the file. File should contain only one table. For example, trc, csv & sto files contain one table whereas a c3d file can contain more than.
tablenameName of the table in file to construct this DataTable_ from. For example, a c3d file contains tables named 'markers' and 'forces'.
Exceptions
InvalidArgumentIf the input file contains more than one table and tablename was not specified.
InvalidArgumentIf the input file contains a table that is not of this DataTable_ type.

◆ DataTable_() [5/9]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename ThatETY >
OpenSim::DataTable_< ETX, ETY >::DataTable_ ( const DataTable_< double, ThatETY > &  that,
const std::vector< std::string > &  suffixes 
)
inline

Construct DataTable_<double, double> from DataTable_<double, ThatETY> where ThatETY can be SimTK::Vec<X>.

Each column of the other table is split into multiple columns of this table. For example , DataTable_<double, Vec3> with 3 columns and 4 rows will construct DataTable<double, double> of 9 columns and 4 rows where each component of SimTK::Vec3 ends up in one column. Column labels of the resulting DataTable will use column labels of source table appended with suffixes provided. This constructor only makes sense for DataTable_<double, double>.

Template Parameters
ThatETYDatatype of the matrix underlying the given DataTable.
Parameters
thatDataTable to copy-construct this table from. This table can be of different SimTK::Vec<X> types, for example DataTable_<double, Vec<3>>, DataTable_<double, Quaternion>, DataTable_<double, Vec6> etc.
suffixesSuffixes to be used for column-labels of individual components/columns in this table when splitting columns of 'that' table. For example a column labeled 'marker' from DataTable_<double, Vec3> will be split into 3 columns named
std::string{'marker' + suffixes[0]},
std::string{'marker' + suffixes[1]},
std::string{'marker' + suffixes[2]}
Exceptions
InvalidArgumentIf 'that' DataTable has no column-labels.
InvalidArgumentIf 'that' DataTable has zero number of rows/columns.
InvalidArgumentIf 'suffixes' does not contain same number of elements as that.numComponentsPerElement().

◆ DataTable_() [6/9]

template<typename ETX = double, typename ETY = SimTK::Real>
OpenSim::DataTable_< ETX, ETY >::DataTable_ ( const DataTable_< double, double > &  that,
const std::vector< std::string > &  suffixes 
)
inlineexplicit

Construct this DataTable from a DataTable_<double, double>.

This is the opposite operation of flatten(). Multiple consecutive columns of the given DataTable will be 'packed' together to form columns of this DataTable. For example, if this DataTable is of type DataTable_<double, Vec3>, then every 3 consecutive columns of the given DataTable will form one column of this DataTable. The column labels of this table will be formed by stripping out the suffixes from the column labels of the given DataTable. For the same example above, if columns labels of the given DataTable are – "col0.x", "col0.y", "col0.x", "col1.x", "col1.y", "col1.x" – the column labels of this DataTable will be – "col0", "col1" – where suffixes are stripped out. This constructor will try to guess the suffixes used. If unable to do so, it will throw an exception. Suffixes used can also be specified as arguments. This constructor only makes sense for DataTable_<double, SimTKType> where SimTKType is not 'double'. SimTKType can be for example, SimTK::Vec3, SimTK::Vec6, SimTK::Quaternion, SimTK::SpatialVec etc.

Parameters
thatDataTable to copy-construct this DataTable from.
suffixesSuffixes used in the input DataTable to distinguish individual components. For example, if column labels are – "force.x", "force.y", "force.z" – suffixes will be – ".x", ".y", ".z".
Exceptions
InvalidArgumentIf 'that' DataTable has no column-labels.
InvalidArgumentIf 'that' DataTable has no rows/columns.
InvalidArgumentIf 'suffixes' does not contain same number of elements as this->numComponentsPerElement().
InvalidArgumentIf number of columns in 'that' DataTable is not a multiple of this->numComponentsPerElement().
InvalidArgumentIf suffixes cannot be extracted from column-labels of 'that' DataTable.

◆ DataTable_() [7/9]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename ThatETY >
OpenSim::DataTable_< ETX, ETY >::DataTable_ ( const DataTable_< double, ThatETY > &  that)
inlineexplicit

Construct DataTable_<double, double> from DataTable_<double, ThatETY> where ThatETY can be SimTK::Vec<X>.

Each column of the other table is split into multiple columns of this table. For example , DataTable_<double, Vec3> with 3 columns and 4 rows will construct DataTable<double, double> of 9 columns and 4 rows where each component of SimTK::Vec3 ends up in one column. Column labels of the resulting DataTable will use column labels of source table appended with suffixes of form "_1", "_2", "_3" and so on.

Template Parameters
ThatETYDatatype of the matrix underlying the given DataTable.
Parameters
thatDataTable to copy-construct this table from. This table can be of for example DataTable_<double, Quaternion>, DataTable_<double, Vec6>.
Exceptions
InvalidArgumentIf 'that' DataTable has no column-labels.
InvalidArgumentIf 'that' DataTable has zero number of rows/columns.
InvalidArgumentIf 'suffixes' does not contain same number of elements as that.numComponentsPerElement().

◆ DataTable_() [8/9]

template<typename ETX = double, typename ETY = SimTK::Real>
OpenSim::DataTable_< ETX, ETY >::DataTable_ ( const std::vector< ETX > &  indVec,
const SimTK::Matrix_< ETY > &  depData,
const std::vector< std::string > &  labels 
)
inlineprotected

Convenience constructor to efficiently populate a DataTable from known data.

This is primarily useful for reading in large data tables without having to reallocate and copy memory. NOTE derived tables must validate the table according to the needs of the concrete type. The virtual validateRow() overridden by derived types cannot be invoked here - that is by the base class. A derived class must perform its own validation by invoking its own validateRow() implementation.

◆ DataTable_() [9/9]

template<typename ETX = double, typename ETY = SimTK::Real>
OpenSim::DataTable_< ETX, ETY >::DataTable_ ( const std::vector< ETX > &  indVec)
inlineprotected

Construct a table with only the independent column and 0 dependent columns.

This constructor is useful when populating the table by appending columns rather than by appending rows.

Member Function Documentation

◆ appendColumn() [1/5]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename Container >
void OpenSim::DataTable_< ETX, ETY >::appendColumn ( const std::string &  columnLabel,
const Container &  container 
)
inline

Append column to the DataTable_ using a sequence container.

std::vector<double> col{1, 2, 3, 4};
table.appendColumn("new-column", col);
Parameters
columnLabelLabel of the column to be added. Must not be same as the label of an existing column.
containerSequence container holding the elements of the column to be appended.
Exceptions
InvalidCallIf DataTable_ contains no rows at the time of this call.
InvalidArgumentIf columnLabel specified already exists in the DataTable_.
InvalidColumnIf the input column contains incorrect number of rows.

Referenced by OpenSim::DataTable_< double, SimTK::Real >::appendColumn().

◆ appendColumn() [2/5]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::appendColumn ( const std::string &  columnLabel,
const std::initializer_list< ETY > &  container 
)
inline

Append column to the DataTable_ using an initializer list.

table.appendColumn("new-column", {1, 2, 3, 4});
Parameters
columnLabelLabel of the column to be added. Must not be same as the label of an existing column.
containerSequence container holding the elements of the column to be appended.
Exceptions
InvalidCallIf DataTable_ contains no rows at the time of this call.
InvalidArgumentIf columnLabel specified already exists in the DataTable_.
InvalidColumnIf the input column contains incorrect number of rows.

◆ appendColumn() [3/5]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename ColIter >
void OpenSim::DataTable_< ETX, ETY >::appendColumn ( const std::string &  columnLabel,
ColIter  begin,
ColIter  end 
)
inline

Append column to the DataTable_ using an iterator pair.

std::vector<double> col{};
// ......
// Fill up 'col'.
// ......
table.append("new-column", col.begin(), col.end());
Parameters
columnLabelLabel of the column to be added. Must not be same as the label of an existing column.
beginIterator referring to the beginning of the range.
endIterator referring to the end of the range.
Exceptions
InvalidCallIf DataTable_ contains no rows at the time of this call.
InvalidArgumentIf columnLabel specified already exists in the DataTable_.
InvalidColumnIf the input column contains incorrect number of rows.

◆ appendColumn() [4/5]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::appendColumn ( const std::string &  columnLabel,
const Vector depCol 
)
inline

Append column to the DataTable_ using a SimTK::Vector.

Parameters
columnLabelLabel of the column to be added. Must not be same as the label of an existing column.
depColColumn vector to be appended to the table.
Exceptions
InvalidCallIf DataTable_ contains no rows at the time of this call.
InvalidArgumentIf columnLabel specified already exists in the DataTable_.
InvalidColumnIf the input column contains incorrect number of rows.

◆ appendColumn() [5/5]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::appendColumn ( const std::string &  columnLabel,
const VectorView depCol 
)
inline

Append column to the DataTable_ using a SimTK::VectorView.

Parameters
columnLabelLabel of the column to be added. Must not be same as the label of an existing column.
depColColumn vector to be appended to the table.
Exceptions
InvalidCallIf DataTable_ contains no rows at the time of this call.
InvalidArgumentIf columnLabel specified already exists in the DataTable_.
InvalidColumnIf the input column contains incorrect number of rows.

◆ appendRow() [1/5]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename Container >
void OpenSim::DataTable_< ETX, ETY >::appendRow ( const ETX &  indRow,
const Container &  container 
)
inline

Append row to the DataTable_.

Parameters
indRowEntry for the independent column corresponding to the row to be appended.
containerSequence container holding the elements of the row to be appended.
Exceptions
IncorrectNumColumnsIf the row added is invalid. Validity of the row added is decided by the derived class.

Referenced by OpenSim::DataTable_< double, SimTK::Real >::appendRow().

◆ appendRow() [2/5]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::appendRow ( const ETX &  indRow,
const std::initializer_list< ETY > &  container 
)
inline

Append row to the DataTable_.

Parameters
indRowEntry for the independent column corresponding to the row to be appended.
containerstd::initializer_list containing elements of the row to be appended.
Exceptions
IncorrectNumColumnsIf the row added is invalid. Validity of the row added is decided by the derived class.

◆ appendRow() [3/5]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename RowIter >
void OpenSim::DataTable_< ETX, ETY >::appendRow ( const ETX &  indRow,
RowIter  begin,
RowIter  end 
)
inline

Append row to the DataTable_.

Parameters
indRowEntry for the independent column corresponding to the row to be appended.
beginIterator representing the beginning of the row to be appended.
endIterator representing one past the end of the row to be appended.
Exceptions
IncorrectNumColumnsIf the row added is invalid. Validity of the row added is decided by the derived class.

◆ appendRow() [4/5]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::appendRow ( const ETX &  indRow,
const RowVector depRow 
)
inline

Append row to the DataTable_.

Exceptions
IncorrectNumColumnsIf the row added is invalid. Validity of the row added is decided by the derived class.

◆ appendRow() [5/5]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::appendRow ( const ETX &  indRow,
const RowVectorView depRow 
)
inline

Append row to the DataTable_.

Exceptions
IncorrectNumColumnsIf the row added is invalid. Validity of the row added is decided by the derived class.

◆ clone()

template<typename ETX = double, typename ETY = SimTK::Real>
std::shared_ptr<AbstractDataTable> OpenSim::DataTable_< ETX, ETY >::clone ( ) const
inlineoverridevirtual

◆ flatten() [1/2]

template<typename ETX = double, typename ETY = SimTK::Real>
DataTable_<double, double> OpenSim::DataTable_< ETX, ETY >::flatten ( ) const
inline

Flatten the columns of this table to create a DataTable_<double, double>.

Each column will be split into its constituent components. For example, each column of a DataTable_<double, Vec3> will be split into 3 columns. The column-labels of the resulting columns will be suffixed "_1", "_2", "_3" and so on. See documentation for constructor DataTable_::DataTable_().

Referenced by OpenSim::MocoTrack::setMarkersReferenceFromTRC().

◆ flatten() [2/2]

template<typename ETX = double, typename ETY = SimTK::Real>
DataTable_<double, double> OpenSim::DataTable_< ETX, ETY >::flatten ( const std::vector< std::string > &  suffixes) const
inline

Flatten the columns of this table to create a DataTable_<double, double>.

Each column will be split into its constituent components. For example, each column of a DataTable_<double, Vec3> will be split into 3 columns. The column-labels of the resulting columns will be appended with 'suffixes' provided. See documentation for constructor DataTable_::DataTable_().

◆ getDependentColumn()

template<typename ETX = double, typename ETY = SimTK::Real>
VectorView OpenSim::DataTable_< ETX, ETY >::getDependentColumn ( const std::string &  columnLabel) const
inline

Get dependent Column which has the given column label.

Exceptions
KeyNotFoundIf columnLabel is not found to be label of any existing column.

◆ getDependentColumnAtIndex()

template<typename ETX = double, typename ETY = SimTK::Real>
VectorView OpenSim::DataTable_< ETX, ETY >::getDependentColumnAtIndex ( size_t  index) const
inline

Get dependent column at index.

Exceptions
EmptyTableIf the table is empty.
ColumnIndexOutOfRangeIf index is out of range for number of columns in the table.

◆ getIndependentColumn()

template<typename ETX = double, typename ETY = SimTK::Real>
const std::vector<ETX>& OpenSim::DataTable_< ETX, ETY >::getIndependentColumn ( ) const
inline

◆ getMatrix()

template<typename ETX = double, typename ETY = SimTK::Real>
const MatrixView& OpenSim::DataTable_< ETX, ETY >::getMatrix ( ) const
inline

Get a read-only view to the underlying matrix.

Referenced by OpenSim::TableSource_< ET >::getColumnAtTime(), and OpenSim::DataTable_< double, SimTK::Real >::toString_impl().

◆ getMatrixBlock()

template<typename ETX = double, typename ETY = SimTK::Real>
MatrixView OpenSim::DataTable_< ETX, ETY >::getMatrixBlock ( size_t  rowStart,
size_t  columnStart,
size_t  numRows,
size_t  numColumns 
) const
inline

Get a read-only view of a block of the underlying matrix.

Exceptions
InvalidArgumentIf numRows or numColumns is zero.
EmptyTableIf the table is empty.
RowIndexOutOfRangeIf one or more rows of the desired block is out of range of the matrix.
ColumnIndexOutOfRangeIf one or more columns of the desired block is out of range of the matrix.

◆ getRow()

template<typename ETX = double, typename ETY = SimTK::Real>
const RowVectorView OpenSim::DataTable_< ETX, ETY >::getRow ( const ETX &  ind) const
inline

Get row corresponding to the given entry in the independent column.

This function searches the independent column for exact equality, which may not be appropriate if ETX is of type double. See TimeSeriesTable_::getNearestRow().

Exceptions
KeyNotFoundIf the independent column has no entry with given value.

◆ getRowAtIndex()

template<typename ETX = double, typename ETY = SimTK::Real>
const RowVectorView OpenSim::DataTable_< ETX, ETY >::getRowAtIndex ( size_t  index) const
inline

Get row at index.

Exceptions
RowIndexOutOfRangeIf index is out of range.

Referenced by OpenSim::analyze(), and OpenSim::TableSource_< ET >::getRowAtTime().

◆ implementGetNumColumns()

template<typename ETX = double, typename ETY = SimTK::Real>
size_t OpenSim::DataTable_< ETX, ETY >::implementGetNumColumns ( ) const
inlineoverrideprotectedvirtual

Get number of columns.

Implements OpenSim::AbstractDataTable.

◆ implementGetNumRows()

template<typename ETX = double, typename ETY = SimTK::Real>
size_t OpenSim::DataTable_< ETX, ETY >::implementGetNumRows ( ) const
inlineoverrideprotectedvirtual

Get number of rows.

Implements OpenSim::AbstractDataTable.

◆ isColumnIndexOutOfRange()

◆ isEmpty()

◆ isRowIndexOutOfRange()

◆ makeElement()

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename Iter >
static ETY OpenSim::DataTable_< ETX, ETY >::makeElement ( Iter  begin,
Iter  end 
)
inlinestaticprotected

◆ makeElement_helper() [1/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename Iter >
static void OpenSim::DataTable_< ETX, ETY >::makeElement_helper ( double &  elem,
Iter  begin,
Iter  end 
)
inlinestaticprotected

◆ makeElement_helper() [2/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<int N, typename Iter >
static void OpenSim::DataTable_< ETX, ETY >::makeElement_helper ( SimTK::Vec< N > &  elem,
Iter  begin,
Iter  end 
)
inlinestaticprotected

◆ makeElement_helper() [3/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<int M, int N, typename Iter >
static void OpenSim::DataTable_< ETX, ETY >::makeElement_helper ( SimTK::Vec< M, SimTK::Vec< N >> &  elem,
Iter  begin,
Iter  end 
)
inlinestaticprotected

◆ makeElement_helper() [4/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<int M, int N, typename Iter >
static void OpenSim::DataTable_< ETX, ETY >::makeElement_helper ( SimTK::Mat< M, N > &  elem,
Iter  begin,
Iter  end 
)
inlinestaticprotected

◆ numComponentsPerElement()

template<typename ETX = double, typename ETY = SimTK::Real>
unsigned OpenSim::DataTable_< ETX, ETY >::numComponentsPerElement ( ) const
inlineoverridevirtual

Retrieve the number of components each element (of type ETY) of the table is made of.

Some examples:

Table Type Element Type Num of Components
DataTable<double, double> double 1
DataTable<double, Vec3> Vec3 3
DataTable<double, Quaternion> Quaternion 4

Implements OpenSim::AbstractDataTable.

Referenced by OpenSim::DataTable_< double, SimTK::Real >::DataTable_(), and OpenSim::DataTable_< double, SimTK::Real >::toString_impl().

◆ numComponentsPerElement_impl() [1/4]

template<typename ETX = double, typename ETY = SimTK::Real>
static constexpr unsigned OpenSim::DataTable_< ETX, ETY >::numComponentsPerElement_impl ( double  )
inlinestaticprotected

◆ numComponentsPerElement_impl() [2/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<int M>
static constexpr unsigned OpenSim::DataTable_< ETX, ETY >::numComponentsPerElement_impl ( SimTK::Vec< M >  )
inlinestaticprotected

◆ numComponentsPerElement_impl() [3/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<int M, int N>
static constexpr unsigned OpenSim::DataTable_< ETX, ETY >::numComponentsPerElement_impl ( SimTK::Mat< M, N >  )
inlinestaticprotected

◆ numComponentsPerElement_impl() [4/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<int M, int N>
static constexpr unsigned OpenSim::DataTable_< ETX, ETY >::numComponentsPerElement_impl ( SimTK::Vec< M, SimTK::Vec< N >>  )
inlinestaticprotected

◆ operator=() [1/3]

template<typename ETX = double, typename ETY = SimTK::Real>
DataTable_& OpenSim::DataTable_< ETX, ETY >::operator= ( const DataTable_< ETX, ETY > &  )
default

◆ operator=() [2/3]

template<typename ETX = double, typename ETY = SimTK::Real>
DataTable_& OpenSim::DataTable_< ETX, ETY >::operator= ( DataTable_< ETX, ETY > &&  )
default

◆ operator=() [3/3]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename ThatETY >
DataTable_& OpenSim::DataTable_< ETX, ETY >::operator= ( const DataTable_< double, ThatETY > &  that)
inline

Copy assign a DataTable_<double, double> from DataTable_<double, ThatETY> where ThatETY can be SimTK::Vec<X>.

Each column of the other table is split into multiple columns of this table. For example , DataTable_<double, Vec3> with 3 columns and 4 rows will construct DataTable<double, double> of 9 columns and 4 rows where each component of SimTK::Vec3 ends up in one column. Column labels of the resulting DataTable will use column labels of source table appended with suffixes of form "_1", "_2", "_3" and so on.

Template Parameters
ThatETYDatatype of the matrix underlying the given DataTable.
Parameters
thatDataTable to copy assign from. This table can be of for example DataTable_<double, Quaternion>, DataTable_<double, Vec6>.
Exceptions
InvalidArgumentIf 'that' DataTable has no column-labels.
InvalidArgumentIf 'that' DataTable has zero number of rows/columns.
InvalidArgumentIf 'suffixes' does not contain same number of elements as that.numComponentsPerElement().

◆ pack() [1/2]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename ThatETY >
DataTable_<double, ThatETY> OpenSim::DataTable_< ETX, ETY >::pack ( ) const
inline

Pack the columns of this table to create a DataTable_<double, ThatETY>, where 'ThatETY' is the template parameter which can be SimTK::Vec3, SimTK::UnitVec3, SimTK::Quaternion, SimTK::SpatialVec and so on.

Multiple consecutive columns of this table will be packed into one column of the resulting table. For example while creating a DataTable_<double, Quaternion> , every group of 4 consecutive columns of this table will form one column of the resulting table. The column-labels of the resulting table will be formed by stripping the suffixes in the column-labels of this table. This function will attempt to guess the suffixes of column-labels. See documentation for constructor DataTable_::DataTable_().

◆ pack() [2/2]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename ThatETY >
DataTable_<double, ThatETY> OpenSim::DataTable_< ETX, ETY >::pack ( const std::vector< std::string > &  suffixes) const
inline

Pack the columns of this table to create a DataTable_<double, ThatETY>, where 'ThatETY' is the template parameter which can be SimTK::Vec3, SimTK::UnitVec3, SimTK::Quaternion, SimTK::SpatialVec and so on.

Multiple consecutive columns of this table will be packed into one column of the resulting table. For example while creating a DataTable_<double, Quaternion> , every group of 4 consecutive columns of this table will form one column of the resulting table. The column-labels of the resulting table will be formed by stripping the suffixes in the column-labels of this table. See documentation for constructor DataTable_::DataTable_().

◆ removeColumn()

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::removeColumn ( const std::string &  columnLabel)
inline

Remove column corresponding to the given dependent column label.

The independent column cannot be removed.

Exceptions
KeyNotFoundIf the independent column has no entry with the given value.

◆ removeColumnAtIndex()

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::removeColumnAtIndex ( size_t  index)
inline

Remove column corresponding to the given column index.

Exceptions
ColumnIndexOutOfRangeIf the index is out of range.

Referenced by OpenSim::DataTable_< double, SimTK::Real >::removeColumn().

◆ removeRow()

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::removeRow ( const ETX &  ind)
inline

Remove row corresponding to the given entry in the independent column.

Exceptions
KeyNotFoundIf the independent column has no entry with the given value.

◆ removeRowAtIndex()

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::removeRowAtIndex ( size_t  index)
inline

Remove row at index.

Exceptions
RowIndexOutOfRangeIf the index is out of range.

Referenced by OpenSim::DataTable_< double, SimTK::Real >::removeRow().

◆ setIndependentValueAtIndex()

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::setIndependentValueAtIndex ( size_t  rowIndex,
const ETX &  value 
)
inline

Set value of the independent column at index.

Exceptions
EmptyTableIf the table is empty.
RowIndexOutOfRangeIf rowIndex is out of range.
InvalidRowIf this operation invalidates the row. Validation is performed by derived classes.

◆ setRow() [1/2]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::setRow ( const ETX &  ind,
const RowVectorView depRow 
)
inline

Set row corresponding to the given entry in the independent column.

This function searches the independent column for exact equality, which may not be appropriate if ETX is of type double. See TimeSeriesTable_::updNearestRow(). Equivalent to

updRow(ind) = depRow;
Exceptions
KeyNotFoundIf the independent column has no entry with given value.

◆ setRow() [2/2]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::setRow ( const ETX &  ind,
const RowVector depRow 
)
inline

Set row corresponding to the given entry in the independent column.

This function searches the independent column for exact equality, which may not be appropriate if ETX is of type double. See TimeSeriesTable_::updNearestRow(). Equivalent to

updRow(ind) = depRow;
Exceptions
KeyNotFoundIf the independent column has no entry with given value.

◆ setRowAtIndex() [1/2]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::setRowAtIndex ( size_t  index,
const RowVectorView depRow 
)
inline

Set row at index.

Equivalent to

updRowAtIndex(index) = depRow;
Exceptions
RowIndexOutOfRangeIf the index is out of range.

◆ setRowAtIndex() [2/2]

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::setRowAtIndex ( size_t  index,
const RowVector depRow 
)
inline

Set row at index.

Equivalent to

updRowAtIndex(index) = depRow;
Exceptions
RowIndexOutOfRangeIf the index is out of range.

◆ splitAndAssignElement() [1/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<int N, typename Iter >
static void OpenSim::DataTable_< ETX, ETY >::splitAndAssignElement ( Iter  begin,
Iter  end,
const SimTK::Vec< N > &  elem 
)
inlinestaticprotected

◆ splitAndAssignElement() [2/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<int M, int N, typename Iter >
static void OpenSim::DataTable_< ETX, ETY >::splitAndAssignElement ( Iter  begin,
Iter  end,
const SimTK::Vec< M, SimTK::Vec< N >> &  elem 
)
inlinestaticprotected

◆ splitAndAssignElement() [3/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<int M, int N, typename Iter >
static void OpenSim::DataTable_< ETX, ETY >::splitAndAssignElement ( Iter  begin,
Iter  end,
const SimTK::Mat< M, N > &  elem 
)
inlinestaticprotected

◆ splitAndAssignElement() [4/4]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename Iter >
static void OpenSim::DataTable_< ETX, ETY >::splitAndAssignElement ( Iter  begin,
Iter  end,
  ... 
)
inlinestaticprotected

◆ splitElement() [1/2]

template<typename ETX = double, typename ETY = SimTK::Real>
template<typename ELT >
static SimTK::RowVector_<double> OpenSim::DataTable_< ETX, ETY >::splitElement ( const ELT &  elt)
inlinestaticprotected

◆ splitElement() [2/2]

template<typename ETX = double, typename ETY = SimTK::Real>
static SimTK::RowVector_<double> OpenSim::DataTable_< ETX, ETY >::splitElement ( const double &  elt)
inlinestaticprotected

◆ toString()

template<typename ETX = double, typename ETY = SimTK::Real>
std::string OpenSim::DataTable_< ETX, ETY >::toString ( std::vector< int >  rows = {},
std::vector< std::string >  columnLabels = {},
const bool  withMetaData = true,
unsigned  splitSize = 25,
unsigned  maxWidth = 80,
unsigned  precision = 4 
) const
inline

Get a string representation of the table, including the key-value pairs in the table metadata.

Table metadata will be of the form:

key => value-converted-to-string

For example:

DataRate => 2000.00000
Units => mm

For values in the table metadata that do not support the operation of stream insertion (operator<<), the value for metadata will be:

key => <cannot-convert-to-string>

Some examples to call this function:

// All rows, all columns.
auto tableAsString = table.toString();
// First 5 rows, all columns.
auto tableAsString = table.toString({0, 1, 2, 3, 4});
// All rows, 3 columns with specified labels.
auto tableAsString = table.toString({}, {"col12", "col35", "col4"});
// Rows 5th, 3rd, 1st (in that order) and columns with specified labels (in
// that order).
auto tableAsString = table.toString({4, 2, 0}, {"col10", "col5", "col2"});
// Lets say the table has 10 rows. Following will get last 3 rows in the
// order specified. All columns.
auto tableAsString = table.toString({-1, -2, -3})
Parameters
rows[Default = all rows] Sequence of indices of rows to be printed. Rows will be printed exactly in the order specified in the sequence. Index begins at 0 (i.e. first row is 0). Negative indices refer to rows starting from last row. Index -1 refers to last row, -2 refers to row previous to last row and so on. Default behavior is to print all rows.
columnLabels[Default = all rows] Sequence of labels of columns to be printed. Columns will be printed exactly in the order specified in the sequence. Default behavior is to print all columns.
withMetaData[Default = true] Whether or not table metadata should be printed. Default behavior is to print table metadata.
splitSize[Default = 25] Number of rows to print at a time. Default behavior is to print 25 rows at a time.
maxWidth[Default = 80] Maximum number of characters to print per line. The columns are split accordingly to make the table readable. This is useful in terminals/consoles with narrow width. Default behavior is to limit number characters per line to 80.
precision[Default = 4] Precision of the floating-point numbers printed. Default behavior is to print floating-point numbers with 4 places to the right of decimal point.

Referenced by OpenSim::operator<<().

◆ toString_impl()

template<typename ETX = double, typename ETY = SimTK::Real>
std::string OpenSim::DataTable_< ETX, ETY >::toString_impl ( std::vector< int >  rows = {},
std::vector< int >  cols = {},
const bool  withMetaData = true,
unsigned  splitSize = 25,
unsigned  maxWidth = 80,
unsigned  precision = 4 
) const
inlineprotected

◆ updDependentColumn()

template<typename ETX = double, typename ETY = SimTK::Real>
VectorView OpenSim::DataTable_< ETX, ETY >::updDependentColumn ( const std::string &  columnLabel)
inline

Update dependent Column which has the given column label.

Exceptions
KeyNotFoundIf columnLabel is not found to be label of any existing column.

◆ updDependentColumnAtIndex()

template<typename ETX = double, typename ETY = SimTK::Real>
VectorView OpenSim::DataTable_< ETX, ETY >::updDependentColumnAtIndex ( size_t  index)
inline

Update dependent column at index.

Exceptions
EmptyTableIf the table is empty.
ColumnIndexOutOfRangeIf index is out of range for number of columns in the table.

◆ updMatrix()

template<typename ETX = double, typename ETY = SimTK::Real>
MatrixView& OpenSim::DataTable_< ETX, ETY >::updMatrix ( )
inline

Get a writable view to the underlying matrix.

◆ updMatrixBlock()

template<typename ETX = double, typename ETY = SimTK::Real>
MatrixView OpenSim::DataTable_< ETX, ETY >::updMatrixBlock ( size_t  rowStart,
size_t  columnStart,
size_t  numRows,
size_t  numColumns 
)
inline

Get a writable view of a block of the underlying matrix.

Exceptions
InvalidArgumentIf numRows or numColumns is zero.
EmptyTableIf the table is empty.
RowIndexOutOfRangeIf one or more rows of the desired block is out of range of the matrix.
ColumnIndexOutOfRangeIf one or more columns of the desired block is out of range of the matrix.

◆ updRow()

template<typename ETX = double, typename ETY = SimTK::Real>
RowVectorView OpenSim::DataTable_< ETX, ETY >::updRow ( const ETX &  ind)
inline

Update row corresponding to the given entry in the independent column.

This function searches the independent column for exact equality, which may not be appropriate if ETX is of type double. See TimeSeriesTable_::updNearestRow().

Exceptions
KeyNotFoundIf the independent column has no entry with given value.

Referenced by OpenSim::DataTable_< double, SimTK::Real >::setRow().

◆ updRowAtIndex()

template<typename ETX = double, typename ETY = SimTK::Real>
RowVectorView OpenSim::DataTable_< ETX, ETY >::updRowAtIndex ( size_t  index)
inline

Update row at index.

Exceptions
RowIndexOutOfRangeIf the index is out of range.

Referenced by OpenSim::DataTable_< double, SimTK::Real >::setRowAtIndex().

◆ validateDependentsMetaData()

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::validateDependentsMetaData ( ) const
inlineoverrideprotectedvirtual

Validate metadata for dependent columns.

Exceptions
MissingMetaDataIf metadata for dependent columns does not contain a key named "labels".
IncorrectMetaDataLength(1) If ValueArray for key "labels" does not have length equal to the number of columns in the table. (2) If not all entries in the metadata for dependent columns have the correct length (equal to number of columns).
InvalidColumnLabel(1) if label is an empty string, (2) if label contains tab or newline characters, or (3) if label has leading or trailing spaces.

Implements OpenSim::AbstractDataTable.

◆ validateIndependentMetaData()

template<typename ETX = double, typename ETY = SimTK::Real>
void OpenSim::DataTable_< ETX, ETY >::validateIndependentMetaData ( ) const
inlineoverrideprotectedvirtual

Validate metadata for independent column.

Exceptions
MissingMetaDataIf independent column's metadata does not contain a key named "labels".

Implements OpenSim::AbstractDataTable.

◆ validateRow()

template<typename ETX = double, typename ETY = SimTK::Real>
virtual void OpenSim::DataTable_< ETX, ETY >::validateRow ( size_t  rowIndex,
const ETX &  ,
const RowVector  
) const
inlineprotectedvirtual

Member Data Documentation

◆ _depData

template<typename ETX = double, typename ETY = SimTK::Real>
SimTK::Matrix_<ETY> OpenSim::DataTable_< ETX, ETY >::_depData
protected

◆ _indData


The documentation for this class was generated from the following file: