API
4.5.1
For C++ developers
|
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... | |
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 |
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. |
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.
|
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. |
|
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(). |
|
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. |
|
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.
|
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.
|
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. |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::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. |
|
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. |
|
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. |
|
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. |
|
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. |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::appendRow(), and OpenSim::TableReporter_< InputT, ValueT >::implementReport().
|
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. |
|
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. |
|
inline |
Append row to the DataTable_.
IncorrectNumColumns | If the row added is invalid. Validity of the row added is decided by the derived class. |
|
inline |
Append row to the DataTable_.
IncorrectNumColumns | If the row added is invalid. Validity of the row added is decided by the derived class. |
|
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_().
Referenced by OpenSim::MocoTrack::setMarkersReferenceFromTRC().
|
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. |
|
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. |
|
inline |
Get independent column.
Referenced by OpenSim::TableSource_< ET >::getColumnAtTime(), and OpenSim::TableSource_< ET >::getRowAtTime().
|
inline |
Get a read-only view to the underlying matrix.
Referenced by OpenSim::TableSource_< ET >::getColumnAtTime().
|
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. |
|
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. |
|
inline |
Get row at index.
RowIndexOutOfRange | If index is out of range. |
Referenced by OpenSim::TableSource_< ET >::getRowAtTime().
|
inlineoverrideprotectedvirtual |
Get number of columns.
Implements OpenSim::AbstractDataTable.
|
inlineoverrideprotectedvirtual |
Get number of rows.
Implements OpenSim::AbstractDataTable.
|
inlineprotected |
Check if column index is out of range.
Referenced by OpenSim::DataTable_< double, SimTK::Real >::getDependentColumnAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::getMatrixBlock(), OpenSim::DataTable_< double, SimTK::Real >::removeColumnAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::updDependentColumnAtIndex(), and OpenSim::DataTable_< double, SimTK::Real >::updMatrixBlock().
|
inlineprotected |
Determine whether table is empty.
Referenced by OpenSim::DataTable_< double, SimTK::Real >::getDependentColumnAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::getMatrixBlock(), OpenSim::DataTable_< double, SimTK::Real >::setIndependentValueAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::updDependentColumnAtIndex(), and OpenSim::DataTable_< double, SimTK::Real >::updMatrixBlock().
|
inlineprotected |
Check if row index is out of range.
Referenced by OpenSim::DataTable_< double, SimTK::Real >::getMatrixBlock(), OpenSim::DataTable_< double, SimTK::Real >::getRowAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::removeRowAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::setIndependentValueAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::updMatrixBlock(), and OpenSim::DataTable_< double, SimTK::Real >::updRowAtIndex().
|
inlinestaticprotected |
|
inlinestaticprotected |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::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.
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
default |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::operator=().
|
default |
|
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(). |
|
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. |
|
inline |
Remove column corresponding to the given column index.
ColumnIndexOutOfRange | If the index is out of range. |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::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. |
|
inline |
Remove row at index.
RowIndexOutOfRange | If the index is out of range. |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::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. |
|
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. |
|
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. |
|
inline |
Set row at index.
Equivalent to
RowIndexOutOfRange | If the index is out of range. |
|
inline |
Set row at index.
Equivalent to
RowIndexOutOfRange | If the index is out of range. |
|
inlinestaticprotected |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::splitElement().
|
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. |
|
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. |
|
inline |
Get a writable view to the underlying matrix.
|
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. |
|
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. |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::setRow().
|
inline |
Update row at index.
RowIndexOutOfRange | If the index is out of range. |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::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.
|
inlineoverrideprotectedvirtual |
Validate metadata for independent column.
MissingMetaData | If independent column's metadata does not contain a key named "labels". |
Implements OpenSim::AbstractDataTable.
|
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_< ETY >, OpenSim::TimeSeriesTable_< SimTK::Rotation_< double > >, OpenSim::TimeSeriesTable_< ET >, OpenSim::TimeSeriesTable_< SimTK::Rotation >, OpenSim::TimeSeriesTable_< ValueT >, OpenSim::TimeSeriesTable_< SimTK::Real >, and OpenSim::TimeSeriesTable_< SimTK::Vec3 >.
Referenced by OpenSim::DataTable_< double, SimTK::Real >::appendRow(), and OpenSim::DataTable_< double, SimTK::Real >::setIndependentValueAtIndex().
|
protected |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::appendColumn(), OpenSim::DataTable_< double, SimTK::Real >::appendRow(), OpenSim::DataTable_< double, SimTK::Real >::DataTable_(), OpenSim::DataTable_< double, SimTK::Real >::getDependentColumn(), OpenSim::DataTable_< double, SimTK::Real >::getDependentColumnAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::getMatrix(), OpenSim::DataTable_< double, SimTK::Real >::getMatrixBlock(), OpenSim::DataTable_< double, SimTK::Real >::getRow(), OpenSim::DataTable_< double, SimTK::Real >::getRowAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::implementGetNumColumns(), OpenSim::DataTable_< double, SimTK::Real >::implementGetNumRows(), OpenSim::DataTable_< double, SimTK::Real >::isColumnIndexOutOfRange(), OpenSim::DataTable_< double, SimTK::Real >::removeColumnAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::removeRowAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::setIndependentValueAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::updDependentColumn(), OpenSim::DataTable_< double, SimTK::Real >::updDependentColumnAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::updMatrix(), OpenSim::DataTable_< double, SimTK::Real >::updMatrixBlock(), OpenSim::DataTable_< double, SimTK::Real >::updRow(), OpenSim::DataTable_< double, SimTK::Real >::updRowAtIndex(), and OpenSim::DataTable_< double, SimTK::Real >::validateDependentsMetaData().
|
protected |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::appendRow(), OpenSim::DataTable_< double, SimTK::Real >::DataTable_(), OpenSim::DataTable_< double, SimTK::Real >::getIndependentColumn(), OpenSim::DataTable_< double, SimTK::Real >::getRow(), OpenSim::DataTable_< double, SimTK::Real >::getRowAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::isRowIndexOutOfRange(), OpenSim::DataTable_< double, SimTK::Real >::removeRow(), OpenSim::DataTable_< double, SimTK::Real >::removeRowAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::setIndependentValueAtIndex(), OpenSim::DataTable_< double, SimTK::Real >::updRow(), and OpenSim::DataTable_< double, SimTK::Real >::updRowAtIndex().