41 #ifndef CORE_DATATYPES_COLUMNMATRIX_H
42 #define CORE_DATATYPES_COLUMNMATRIX_H 1
44 #include <Core/Util/FancyAssert.h>
125 virtual void print(std::string&)
const;
142 template <
typename T>
145 template <
typename T>
154 template <
typename T>
161 data_ =
new double[this->
nrows_];
166 template <
typename T>
168 Matrix<double>(c.nrows_, 1)
174 data_ =
new double[this->
nrows_];
176 data_[i] = c.data_[i];
184 template <
typename T>
191 template <
typename T>
198 template <
typename T>
205 template <
typename T>
209 return this->nrows();
212 template <
typename T>
219 (*dm)[0][i] = data_[i];
224 template <
typename T>
230 template <
typename T>
233 if (this->nrows_ != c.
nrows_) {
236 data_ =
new T[this->nrows_];
240 data_[i] = c.data_[i];
245 template <
typename T>
256 template <
typename T>
267 template <
typename T>
274 template <
typename T>
279 data_ =
new T[new_rows];
282 this->nrows_ = new_rows;
285 template <
typename T>
288 std::fill(data_, data_ + this->nrows_, 0.0);
293 template <
typename T>
297 std::ostringstream oss;
300 oss << data_[i] <<
"\n";
302 str.assign(oss.str());
305 template <
typename T>
314 template <
typename T>
323 template <
typename T>
332 template <
typename T>
345 template <
typename T>
358 template <
typename T>
363 ASSERTFAIL(
"Error - called mult on a columnmatrix.\n");
366 template <
typename T>
371 ASSERTFAIL(
"Error - called mult_transpose on a columnmatrix.\n");
374 #define COLUMNMATRIX_VERSION 3
376 template <
typename T>
389 int nrows =
static_cast<int>(this->nrows_);
391 this->nrows_ =
static_cast<size_type>(nrows);
395 long long nrows=
static_cast<long long>(this->nrows_);
397 this->nrows_ =
static_cast<size_type>(nrows);
402 data_ =
new T[this->nrows_];
405 if (!stream.
block_io(data_,
sizeof(T), this->nrows_))
415 template <
typename T>
425 template <
typename T>
436 memcpy(mat->data_, data_ + r1, (r2 - r1 + 1) *
sizeof(T));
441 template <
typename T>
447 if (this->nrows_ != m.
nrows())
449 ASSERTFAIL(
"Cannot compute exterior of two vectors of unequal dimensions.");
455 ret.
put(i, j,
get(j) * m.
get(i));
virtual DenseColMajMatrixGeneric< T > * dense_col_maj()
Definition: MatrixTypeConverter.h:253
virtual void put(index_type r, index_type c, T val)
Definition: DenseMatrix.h:423
virtual void getRowNonzerosNoCopy(index_type r, size_type &size, index_type &stride, index_type *&cols, T *&vals)
Definition: ColumnMatrix.h:347
virtual bool block_io(void *, size_t, size_t)
Definition: Persistent.h:174
bool reading() const
Definition: Persistent.h:164
Definition: DenseMatrix.h:68
static PersistentTypeID type_id
Definition: ColumnMatrix.h:130
LockingHandle< Matrix< double > > MatrixHandle
Definition: MatrixFwd.h:55
virtual void io(Piostream &)
Definition: ColumnMatrix.h:377
Definition: DenseColMajMatrix.h:73
virtual void io(bool &)
Definition: Persistent.cc:193
Definition: Persistent.h:89
virtual void print(std::string &) const
Definition: ColumnMatrix.h:295
virtual void mult_transpose(const ColumnMatrix &x, ColumnMatrix &b, index_type beg=-1, index_type end=-1, int spVec=0) const
Definition: ColumnMatrix.h:368
#define COLUMNMATRIX_VERSION
Definition: ColumnMatrix.h:374
virtual void scalar_multiply(T s)
Definition: ColumnMatrix.h:417
#define ASSERTEQ(c1, c2)
Definition: Assert.h:98
int compute_checksum(T *data, std::size_t length)
Definition: CheckSum.h:38
virtual Matrix< T > * make_transpose() const
Definition: ColumnMatrix.h:214
T sumOfCol(index_type)
Definition: ColumnMatrix.h:334
Definition: Persistent.h:187
T infinity_norm() const
Definition: ColumnMatrixFunctions.h:83
#define ASSERT(condition)
Definition: Assert.h:110
virtual int begin_class(const std::string &name, int current_version)
Definition: Persistent.cc:143
#define ASSERTRANGE(c, l, h)
Definition: Assert.h:99
DenseMatrix exterior(const ColumnMatrixGeneric &) const
Definition: ColumnMatrix.h:443
virtual SparseRowMatrixGeneric< T > * sparse()
Definition: MatrixTypeConverter.h:265
ColumnMatrixGeneric< double > ColumnMatrix
Definition: MatrixFwd.h:48
virtual std::string dynamic_type_name() const
Definition: ColumnMatrix.h:128
Definition: ParallelLinearAlgebraTests.cc:358
virtual int compute_checksum()
Definition: ColumnMatrix.h:147
virtual T min()
Definition: ColumnMatrix.h:247
long long size_type
Definition: Types.h:40
T * end() const
Definition: Matrix.h:141
virtual ColumnMatrixGeneric< T > * column()
Definition: MatrixTypeConverter.h:234
Definition: ColumnMatrix.h:55
std::string type
Definition: Persistent.h:72
size_type nrows_
Definition: Matrix.h:112
virtual T * get_data_pointer() const
Definition: ColumnMatrix.h:200
ColumnMatrixGeneric & operator=(const ColumnMatrixGeneric &)
Definition: ColumnMatrix.h:231
T get(index_type r) const
Definition: ColumnMatrix.h:82
virtual DenseMatrix * dense()
Convert this matrix to the specified type.
Definition: MatrixTypeConverter.h:241
virtual ColumnMatrixGeneric * clone() const
Make a duplicate, needed to support detach from LockingHandle.
Definition: ColumnMatrix.h:225
#define ASSERTFAIL(string)
Definition: Assert.h:52
void resize(size_type)
Definition: ColumnMatrix.h:275
virtual T & operator()(index_type i, index_type j)
Definition: ColumnMatrix.h:185
virtual void zero()
Definition: ColumnMatrix.h:286
virtual void end_class()
Definition: Persistent.cc:178
virtual void add(index_type row, index_type col, T val)
Definition: ColumnMatrix.h:325
long long index_type
Definition: Types.h:39
T vector_norm() const
Definition: ColumnMatrixFunctions.h:61
virtual ~ColumnMatrixGeneric()
Definition: ColumnMatrix.h:268
virtual void io(Piostream &)
Definition: Matrix.cc:58
virtual void mult(const ColumnMatrix &x, ColumnMatrix &b, index_type beg=-1, index_type end=-1, int spVec=0) const
Definition: ColumnMatrix.h:360
virtual size_type get_data_size() const
Definition: ColumnMatrix.h:207
Definition: Persistent.h:64
void put(index_type r, T val)
Definition: ColumnMatrix.h:84
ColumnMatrixGeneric(size_type rows=0)
Definition: ColumnMatrix.h:155
virtual T max()
Definition: ColumnMatrix.h:258
T & operator[](int r) const
Definition: ColumnMatrix.h:74
#define DEBUG_CONSTRUCTOR(type)
Definition: Debug.h:64
virtual MatrixHandle submatrix(index_type r1, index_type c1, index_type r2, index_type c2)
Definition: ColumnMatrix.h:427
void set_data(T *d)
Definition: ColumnMatrix.h:80
DenseMatrixGeneric< double > DenseMatrix
Definition: MatrixFwd.h:44
size_type nrows() const
Definition: Matrix.h:132
Definition: MatrixFwd.h:40
int size
Definition: eabLatVolData.py:2
#define DEBUG_DESTRUCTOR(type)
Definition: Debug.h:65