API 4.4.1-2022-10-19-2c4045e59
For MATLAB, Python, Java, and C++ users
|
DataTable_ is an in-memory storage container for data with support for holding metadata (using the base class AbstractDataTable). More...
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< AbstractDataTable > | clone () 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 MatrixView & | getMatrix () 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... | |
MatrixView & | updMatrix () |
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 | |
AbstractDataTable & | operator= (const AbstractDataTable &)=default |
AbstractDataTable & | operator= (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 TableMetaData & | getTableMetaData () const |
Get metadata associated with the table. More... | |
TableMetaData & | updTableMetaData () |
Update metadata associated with the table. More... | |
const IndependentMetaData & | getIndependentMetaData () const |
Get metadata associated with the independent column. More... | |
void | setIndependentMetaData (const IndependentMetaData &independentMetaData) |
Set metadata associated with the independent column. More... | |
const DependentsMetaData & | getDependentsMetaData () 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... | |
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.
ETX | Type of each element of the column holding independent data. |
ETY | Type of each element of the underlying matrix holding dependent data. |
|
default |
|
default |
|
default |
|
default |
|
inline |
Construct DataTable_ from a file.
filename | Name 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. |
tablename | Name of the table in file to construct this DataTable_ from. For example, a c3d file contains tables named 'markers' and 'forces'. |
InvalidArgument | If the input file contains more than one table and tablename was not specified. |
InvalidArgument | If the input file contains a table that is not of this DataTable_ type. |
References OpenSim::FileAdapter::createAdapterFromExtension().
|
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>.
ThatETY | Datatype of the matrix underlying the given DataTable. |
that | DataTable 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. |
suffixes | Suffixes 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]}
|
InvalidArgument | If 'that' DataTable has no column-labels. |
InvalidArgument | If 'that' DataTable has zero number of rows/columns. |
InvalidArgument | If 'suffixes' does not contain same number of elements as that.numComponentsPerElement(). |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::AbstractDataTable::_dependentsMetaData, OpenSim::DataTable_< ETX, ETY >::_indData, OpenSim::AbstractDataTable::getColumnLabels(), OpenSim::DataTable_< ETX, ETY >::getIndependentColumn(), OpenSim::ValueArrayDictionary::getKeys(), OpenSim::AbstractDataTable::getNumColumns(), OpenSim::AbstractDataTable::getNumRows(), OpenSim::DataTable_< ETX, ETY >::getRowAtIndex(), OpenSim::AbstractDataTable::hasColumnLabels(), OpenSim::DataTable_< ETX, ETY >::numComponentsPerElement(), OpenSim::ValueArrayDictionary::removeValueArrayForKey(), OpenSim::AbstractDataTable::setColumnLabels(), OpenSim::DataTable_< ETX, ETY >::splitAndAssignElement(), and OpenSim::ValueArrayDictionary::updValueArrayForKey().
|
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.
that | DataTable to copy-construct this DataTable from. |
suffixes | Suffixes 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". |
InvalidArgument | If 'that' DataTable has no column-labels. |
InvalidArgument | If 'that' DataTable has no rows/columns. |
InvalidArgument | If 'suffixes' does not contain same number of elements as this->numComponentsPerElement(). |
InvalidArgument | If number of columns in 'that' DataTable is not a multiple of this->numComponentsPerElement(). |
InvalidArgument | If suffixes cannot be extracted from column-labels of 'that' DataTable. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::_indData, OpenSim::AbstractDataTable::getColumnLabels(), OpenSim::DataTable_< ETX, ETY >::getIndependentColumn(), OpenSim::AbstractDataTable::getNumColumns(), OpenSim::AbstractDataTable::getNumRows(), OpenSim::DataTable_< ETX, ETY >::getRowAtIndex(), OpenSim::AbstractDataTable::hasColumnLabels(), OpenSim::DataTable_< ETX, ETY >::makeElement(), OpenSim::DataTable_< ETX, ETY >::numComponentsPerElement(), and OpenSim::AbstractDataTable::setColumnLabels().
|
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.
ThatETY | Datatype of the matrix underlying the given DataTable. |
that | DataTable to copy-construct this table from. This table can be of for example DataTable_<double, Quaternion>, DataTable_<double, Vec6>. |
InvalidArgument | If 'that' DataTable has no column-labels. |
InvalidArgument | If 'that' DataTable has zero number of rows/columns. |
InvalidArgument | If 'suffixes' does not contain same number of elements as that.numComponentsPerElement(). |
|
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.
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::_indData, and OpenSim::AbstractDataTable::setColumnLabels().
|
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.
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::_indData, and OpenSim::AbstractDataTable::setColumnLabels().
typedef SimTK::Matrix_<ETY> OpenSim::DataTable_< ETX, ETY >::Matrix |
Type of the matrix holding the dependent data.
typedef SimTK::MatrixView_<ETY> OpenSim::DataTable_< ETX, ETY >::MatrixView |
(Read only view) Type of the matrix holding the dependent data.
typedef SimTK::RowVector_<ETY> OpenSim::DataTable_< ETX, ETY >::RowVector |
Type of each row of matrix holding dependent data.
typedef SimTK::RowVectorView_<ETY> OpenSim::DataTable_< ETX, ETY >::RowVectorView |
(Read only view) Type of each row of matrix.
typedef SimTK::Vector_<ETY> OpenSim::DataTable_< ETX, ETY >::Vector |
Type of each column of matrix holding dependent data.
typedef SimTK::VectorView_<ETY> OpenSim::DataTable_< ETX, ETY >::VectorView |
Type of each column of matrix holding dependent data.
|
inline |
Append column to the DataTable_ using an iterator pair.
columnLabel | Label of the column to be added. Must not be same as the label of an existing column. |
begin | Iterator referring to the beginning of the range. |
end | Iterator referring to the end of the range. |
InvalidCall | If DataTable_ contains no rows at the time of this call. |
InvalidArgument | If columnLabel specified already exists in the DataTable_. |
InvalidColumn | If the input column contains incorrect number of rows. |
References OpenSim::DataTable_< ETX, ETY >::appendColumn().
|
inline |
Append column to the DataTable_ using a sequence container.
columnLabel | Label of the column to be added. Must not be same as the label of an existing column. |
container | Sequence container holding the elements of the column to be appended. |
InvalidCall | If DataTable_ contains no rows at the time of this call. |
InvalidArgument | If columnLabel specified already exists in the DataTable_. |
InvalidColumn | If the input column contains incorrect number of rows. |
References OpenSim::DataTable_< ETX, ETY >::appendColumn().
Referenced by OpenSim::DataTable_< ETX, ETY >::appendColumn().
|
inline |
Append column to the DataTable_ using an initializer list.
columnLabel | Label of the column to be added. Must not be same as the label of an existing column. |
container | Sequence container holding the elements of the column to be appended. |
InvalidCall | If DataTable_ contains no rows at the time of this call. |
InvalidArgument | If columnLabel specified already exists in the DataTable_. |
InvalidColumn | If the input column contains incorrect number of rows. |
References OpenSim::DataTable_< ETX, ETY >::appendColumn().
|
inline |
Append column to the DataTable_ using a SimTK::Vector.
columnLabel | Label of the column to be added. Must not be same as the label of an existing column. |
depCol | Column vector to be appended to the table. |
InvalidCall | If DataTable_ contains no rows at the time of this call. |
InvalidArgument | If columnLabel specified already exists in the DataTable_. |
InvalidColumn | If the input column contains incorrect number of rows. |
References OpenSim::DataTable_< ETX, ETY >::appendColumn().
|
inline |
Append column to the DataTable_ using a SimTK::VectorView.
columnLabel | Label of the column to be added. Must not be same as the label of an existing column. |
depCol | Column vector to be appended to the table. |
InvalidCall | If DataTable_ contains no rows at the time of this call. |
InvalidArgument | If columnLabel specified already exists in the DataTable_. |
InvalidColumn | If the input column contains incorrect number of rows. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::AbstractDataTable::appendColumnLabel(), OpenSim::AbstractDataTable::getNumRows(), and OpenSim::AbstractDataTable::hasColumn().
|
inline |
Append row to the DataTable_.
indRow | Entry for the independent column corresponding to the row to be appended. |
container | Sequence container holding the elements of the row to be appended. |
IncorrectNumColumns | If the row added is invalid. Validity of the row added is decided by the derived class. |
References OpenSim::DataTable_< ETX, ETY >::appendRow().
Referenced by OpenSim::DataTable_< ETX, ETY >::appendRow().
|
inline |
Append row to the DataTable_.
IncorrectNumColumns | If the row added is invalid. Validity of the row added is decided by the derived class. |
References OpenSim::DataTable_< ETX, ETY >::appendRow().
|
inline |
Append row to the DataTable_.
IncorrectNumColumns | If the row added is invalid. Validity of the row added is decided by the derived class. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::AbstractDataTable::_dependentsMetaData, OpenSim::DataTable_< ETX, ETY >::_indData, OpenSim::ValueArrayDictionary::getValueArrayForKey(), OpenSim::ValueArrayDictionary::hasKey(), and OpenSim::DataTable_< ETX, ETY >::validateRow().
|
inline |
Append row to the DataTable_.
indRow | Entry for the independent column corresponding to the row to be appended. |
container | std::initializer_list containing elements of the row to be appended. |
IncorrectNumColumns | If the row added is invalid. Validity of the row added is decided by the derived class. |
References OpenSim::DataTable_< ETX, ETY >::appendRow().
|
inline |
Append row to the DataTable_.
indRow | Entry for the independent column corresponding to the row to be appended. |
begin | Iterator representing the beginning of the row to be appended. |
end | Iterator representing one past the end of the row to be appended. |
IncorrectNumColumns | If the row added is invalid. Validity of the row added is decided by the derived class. |
References OpenSim::DataTable_< ETX, ETY >::appendRow().
|
inlineoverridevirtual |
Implements OpenSim::AbstractDataTable.
|
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_().
|
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_().
|
inline |
Get dependent Column which has the given column label.
KeyNotFound | If columnLabel is not found to be label of any existing column. |
References OpenSim::DataTable_< ETX, ETY >::_depData, and OpenSim::AbstractDataTable::getColumnIndex().
|
inline |
Get dependent column at index.
EmptyTable | If the table is empty. |
ColumnIndexOutOfRange | If index is out of range for number of columns in the table. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::isColumnIndexOutOfRange(), and OpenSim::DataTable_< ETX, ETY >::isEmpty().
|
inline |
Get independent column.
References OpenSim::DataTable_< ETX, ETY >::_indData.
Referenced by OpenSim::DataTable_< ETX, ETY >::DataTable_().
|
inline |
Get a read-only view to the underlying matrix.
References OpenSim::DataTable_< ETX, ETY >::_depData.
|
inline |
Get a read-only view of a block of the underlying matrix.
InvalidArgument | If numRows or numColumns is zero. |
EmptyTable | If the table is empty. |
RowIndexOutOfRange | If one or more rows of the desired block is out of range of the matrix. |
ColumnIndexOutOfRange | If one or more columns of the desired block is out of range of the matrix. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::isColumnIndexOutOfRange(), OpenSim::DataTable_< ETX, ETY >::isEmpty(), and OpenSim::DataTable_< ETX, ETY >::isRowIndexOutOfRange().
|
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().
KeyNotFound | If the independent column has no entry with given value. |
References OpenSim::DataTable_< ETX, ETY >::_depData, and OpenSim::DataTable_< ETX, ETY >::_indData.
|
inline |
Get row at index.
RowIndexOutOfRange | If index is out of range. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::_indData, and OpenSim::DataTable_< ETX, ETY >::isRowIndexOutOfRange().
Referenced by OpenSim::DataTable_< ETX, ETY >::DataTable_().
|
inlineoverrideprotectedvirtual |
Get number of columns.
Implements OpenSim::AbstractDataTable.
References OpenSim::DataTable_< ETX, ETY >::_depData.
|
inlineoverrideprotectedvirtual |
Get number of rows.
Implements OpenSim::AbstractDataTable.
References OpenSim::DataTable_< ETX, ETY >::_depData.
|
inlineprotected |
Check if column index is out of range.
References OpenSim::DataTable_< ETX, ETY >::_depData.
Referenced by OpenSim::DataTable_< ETX, ETY >::getDependentColumnAtIndex(), OpenSim::DataTable_< ETX, ETY >::getMatrixBlock(), OpenSim::DataTable_< ETX, ETY >::removeColumnAtIndex(), OpenSim::DataTable_< ETX, ETY >::updDependentColumnAtIndex(), and OpenSim::DataTable_< ETX, ETY >::updMatrixBlock().
|
inlineprotected |
Determine whether table is empty.
References OpenSim::AbstractDataTable::getNumColumns(), and OpenSim::AbstractDataTable::getNumRows().
Referenced by OpenSim::DataTable_< ETX, ETY >::getDependentColumnAtIndex(), OpenSim::DataTable_< ETX, ETY >::getMatrixBlock(), OpenSim::DataTable_< ETX, ETY >::setIndependentValueAtIndex(), OpenSim::DataTable_< ETX, ETY >::updDependentColumnAtIndex(), and OpenSim::DataTable_< ETX, ETY >::updMatrixBlock().
|
inlineprotected |
Check if row index is out of range.
References OpenSim::DataTable_< ETX, ETY >::_indData.
Referenced by OpenSim::DataTable_< ETX, ETY >::getMatrixBlock(), OpenSim::DataTable_< ETX, ETY >::getRowAtIndex(), OpenSim::DataTable_< ETX, ETY >::removeRowAtIndex(), OpenSim::DataTable_< ETX, ETY >::setIndependentValueAtIndex(), OpenSim::DataTable_< ETX, ETY >::updMatrixBlock(), and OpenSim::DataTable_< ETX, ETY >::updRowAtIndex().
|
inlinestaticprotected |
References OpenSim::DataTable_< ETX, ETY >::makeElement_helper().
Referenced by OpenSim::DataTable_< ETX, ETY >::DataTable_().
|
inlinestaticprotected |
Referenced by OpenSim::DataTable_< ETX, ETY >::makeElement().
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
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.
References OpenSim::DataTable_< ETX, ETY >::numComponentsPerElement_impl().
Referenced by OpenSim::DataTable_< ETX, ETY >::DataTable_().
|
inlinestaticconstexprprotected |
|
inlinestaticconstexprprotected |
|
inlinestaticconstexprprotected |
|
inlinestaticconstexprprotected |
|
default |
Referenced by OpenSim::DataTable_< ETX, ETY >::operator=().
|
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.
ThatETY | Datatype of the matrix underlying the given DataTable. |
that | DataTable to copy assign from. This table can be of for example DataTable_<double, Quaternion>, DataTable_<double, Vec6>. |
InvalidArgument | If 'that' DataTable has no column-labels. |
InvalidArgument | If 'that' DataTable has zero number of rows/columns. |
InvalidArgument | If 'suffixes' does not contain same number of elements as that.numComponentsPerElement(). |
References OpenSim::DataTable_< ETX, ETY >::operator=().
|
default |
|
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_().
|
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_().
|
inline |
Remove column corresponding to the given dependent column label.
The independent column cannot be removed.
KeyNotFound | If the independent column has no entry with the given value. |
References OpenSim::AbstractDataTable::getColumnLabels(), and OpenSim::DataTable_< ETX, ETY >::removeColumnAtIndex().
|
inline |
Remove column corresponding to the given column index.
ColumnIndexOutOfRange | If the index is out of range. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::AbstractDataTable::getColumnLabels(), OpenSim::AbstractDataTable::getNumColumns(), OpenSim::DataTable_< ETX, ETY >::isColumnIndexOutOfRange(), and OpenSim::AbstractDataTable::setColumnLabels().
Referenced by OpenSim::DataTable_< ETX, ETY >::removeColumn().
|
inline |
Remove row corresponding to the given entry in the independent column.
KeyNotFound | If the independent column has no entry with the given value. |
References OpenSim::DataTable_< ETX, ETY >::_indData, and OpenSim::DataTable_< ETX, ETY >::removeRowAtIndex().
|
inline |
Remove row at index.
RowIndexOutOfRange | If the index is out of range. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::_indData, OpenSim::AbstractDataTable::getNumRows(), and OpenSim::DataTable_< ETX, ETY >::isRowIndexOutOfRange().
Referenced by OpenSim::DataTable_< ETX, ETY >::removeRow().
|
inline |
Set value of the independent column at index.
EmptyTable | If the table is empty. |
RowIndexOutOfRange | If rowIndex is out of range. |
InvalidRow | If this operation invalidates the row. Validation is performed by derived classes. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::_indData, OpenSim::DataTable_< ETX, ETY >::isEmpty(), OpenSim::DataTable_< ETX, ETY >::isRowIndexOutOfRange(), and OpenSim::DataTable_< ETX, ETY >::validateRow().
|
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
KeyNotFound | If the independent column has no entry with given value. |
References OpenSim::DataTable_< ETX, ETY >::updRow().
|
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
KeyNotFound | If the independent column has no entry with given value. |
References OpenSim::DataTable_< ETX, ETY >::updRow().
|
inline |
Set row at index.
Equivalent to
RowIndexOutOfRange | If the index is out of range. |
References OpenSim::DataTable_< ETX, ETY >::updRowAtIndex().
|
inline |
Set row at index.
Equivalent to
RowIndexOutOfRange | If the index is out of range. |
References OpenSim::DataTable_< ETX, ETY >::updRowAtIndex().
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inline |
Get a string representation of the table, including the key-value pairs in the table metadata.
Table metadata will be of the form:
For example:
For values in the table metadata that do not support the operation of stream insertion (operator<<), the value for metadata will be:
Some examples to call this function:
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<<().
|
inlineprotected |
|
inline |
Update dependent Column which has the given column label.
KeyNotFound | If columnLabel is not found to be label of any existing column. |
References OpenSim::DataTable_< ETX, ETY >::_depData, and OpenSim::AbstractDataTable::getColumnIndex().
|
inline |
Update dependent column at index.
EmptyTable | If the table is empty. |
ColumnIndexOutOfRange | If index is out of range for number of columns in the table. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::isColumnIndexOutOfRange(), and OpenSim::DataTable_< ETX, ETY >::isEmpty().
|
inline |
|
inline |
Get a writable view of a block of the underlying matrix.
InvalidArgument | If numRows or numColumns is zero. |
EmptyTable | If the table is empty. |
RowIndexOutOfRange | If one or more rows of the desired block is out of range of the matrix. |
ColumnIndexOutOfRange | If one or more columns of the desired block is out of range of the matrix. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::isColumnIndexOutOfRange(), OpenSim::DataTable_< ETX, ETY >::isEmpty(), and OpenSim::DataTable_< ETX, ETY >::isRowIndexOutOfRange().
|
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().
KeyNotFound | If the independent column has no entry with given value. |
References OpenSim::DataTable_< ETX, ETY >::_depData, and OpenSim::DataTable_< ETX, ETY >::_indData.
Referenced by OpenSim::DataTable_< ETX, ETY >::setRow().
|
inline |
Update row at index.
RowIndexOutOfRange | If the index is out of range. |
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::DataTable_< ETX, ETY >::_indData, and OpenSim::DataTable_< ETX, ETY >::isRowIndexOutOfRange().
Referenced by OpenSim::DataTable_< ETX, ETY >::setRowAtIndex().
|
inlineoverrideprotectedvirtual |
Validate metadata for dependent columns.
MissingMetaData | If 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.
References OpenSim::DataTable_< ETX, ETY >::_depData, OpenSim::AbstractDataTable::_dependentsMetaData, OpenSim::AbstractDataTable::getColumnLabels(), OpenSim::ValueArrayDictionary::getKeys(), OpenSim::ValueArrayDictionary::getValueArrayForKey(), OpenSim::ValueArrayDictionary::hasKey(), and OpenSim::AbstractValueArray::size().
|
inlineoverrideprotectedvirtual |
Validate metadata for independent column.
MissingMetaData | If independent column's metadata does not contain a key named "labels". |
Implements OpenSim::AbstractDataTable.
References OpenSim::AbstractDataTable::_independentMetaData, and OpenSim::ValueArrayDictionary::getValueForKey().
|
inlineprotectedvirtual |
Derived classes optionally can implement this function to validate append/update operations.
InvalidRow | If the given row considered invalid by the derived class. |
Reimplemented in OpenSim::TimeSeriesTable_< SimTK::Real >.
Referenced by OpenSim::DataTable_< ETX, ETY >::appendRow(), and OpenSim::DataTable_< ETX, ETY >::setIndependentValueAtIndex().