10#include "MantidDataObjects/DllConfig.h"
13#include <boost/algorithm/string/join.hpp>
14#include <boost/algorithm/string/trim.hpp>
15#include <boost/lexical_cast.hpp>
19namespace DataObjects {
37 const std::type_info &
get_type_info()
const override {
return typeid(std::vector<Type>); }
43 void print(
size_t index, std::ostream &s)
const override {
46 auto it = values.begin();
48 if (it != values.end()) {
53 for (; it != values.end(); ++it) {
60 void read(
size_t index,
const std::string &text)
override {
61 std::vector<Type> newValues;
64 for (
const auto &element : elements) {
66 newValues.emplace_back(boost::lexical_cast<Type>(element));
67 }
catch (boost::bad_lexical_cast &) {
68 throw std::invalid_argument(
"Unable to convert one of the elements: " + element);
76 void read(
const size_t index, std::istringstream &in)
override {
83 bool isBool()
const override {
return false; }
85 bool isNumber()
const override {
return false; }
91 for (
auto elemIt =
m_data.begin(); elemIt !=
m_data.end(); ++elemIt) {
92 dataSize +=
static_cast<long int>(elemIt->size() *
sizeof(Type));
101 newColumn->m_data =
m_data;
102 newColumn->setName(m_name);
103 newColumn->setPlotType(m_plotType);
110 throw std::runtime_error(
"VectorColumn is not convertible to double.");
117 throw std::runtime_error(
"VectorColumn is not assignable from double.");
121 const std::vector<std::vector<Type>> &
data()
const {
return m_data; }
124 if (!possibleToCompare(otherColumn)) {
128 const auto &otherData = otherColumnTyped.
data();
129 for (
size_t i = 0; i <
m_data.size(); i++) {
130 if (
m_data[i].size() != otherData[i].
size()) {
133 for (
size_t j = 0; j <
m_data[i].size(); j++) {
143 if (!possibleToCompare(otherColumn)) {
147 const auto &otherData = otherColumnTyped.
data();
148 for (
size_t i = 0; i <
m_data.size(); i++) {
149 if (
m_data[i].size() != otherData[i].
size()) {
152 for (
size_t j = 0; j <
m_data[i].size(); j++) {
153 double num =
fabs((
double)
m_data[i][j] - (
double)otherData[i][j]);
154 double den = (
fabs((
double)
m_data[i][j]) +
fabs((
double)otherData[i][j])) / 2;
155 if (den < tolerance && num >
tolerance) {
196#define DECLARE_VECTORCOLUMN(Type, TypeName) \
197 template <> std::string VectorColumn<Type>::typeName() { return #TypeName; } \
198 Kernel::RegistrationHelper register_column_##TypeName( \
199 (API::ColumnFactory::Instance().subscribe<VectorColumn<Type>>(#TypeName), 0));
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
const std::vector< Type > & m_data
Column is the base class for columns of TableWorkspace.
VectorColumn : table column type capable of storing vectors of primitive types.
void resize(size_t count) override
Sets the new column size.
const std::type_info & get_pointer_type_info() const override
Returns typeid for the pointer type to the data element in the column.
bool isBool() const override
Specialized type check.
long int sizeOfData() const override
Overall memory size taken by the column (bytes)
void read(const size_t index, std::istringstream &in) override
Set item from a stream.
void read(size_t index, const std::string &text) override
Set item from a string value.
void fromDouble(size_t i, double value) override
Assign from double.
const void * void_pointer(size_t index) const override
Pointer to a data element.
void print(size_t index, std::ostream &s) const override
Print specified item to the stream.
void insert(size_t index) override
Inserts an item.
VectorColumn * clone() const override
Create another copy of the column.
std::string typeName()
Returns the name of the column with the given type.
void remove(size_t index) override
Removes an item.
const std::type_info & get_type_info() const override
Returns typeid for the data in the column.
bool equals(const Column &otherColumn, double tolerance) const override
double toDouble(size_t i) const override
Cast to double.
size_t size() const override
Number of individual elements in the column.
bool isNumber() const override
Are elements of the column interpretable as a number?
void * void_pointer(size_t index) override
Pointer to a data element.
const std::vector< std::vector< Type > > & data() const
Reference to the data.
bool equalsRelErr(const Column &otherColumn, double tolerance) const override
std::vector< std::vector< Type > > m_data
All the vectors stored.
@ TOK_TRIM
remove leading and trailing whitespace from tokens
Helper class which provides the Collimation Length for SANS instruments.