Matrix.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::Matrix
29 
30 Description
31  A templated (m x n) matrix of objects of <T>.
32  The layout is (mRows x nCols) - row-major order:
33 
34  \verbatim
35  (0,0)
36  +---> j [nCols]
37  |
38  |
39  v
40  i [mRows]
41  \endverbatim
42 
43 SourceFiles
44  Matrix.C
45  MatrixI.H
46  MatrixIO.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef Foam_Matrix_H
51 #define Foam_Matrix_H
52 
53 #include "uLabel.H"
54 #include "Pair.H"
55 #include "Field.H"
56 #include "autoPtr.H"
57 #include "complex.H"
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 namespace Foam
62 {
63 
64 // Forward Declarations
65 template<class Form, class Type> class Matrix;
66 template<class MatrixType> class ConstMatrixBlock;
67 template<class MatrixType> class MatrixBlock;
68 
69 template<class Form, class Type>
71 
72 template<class Form, class Type>
73 Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat);
74 
75 
76 /*---------------------------------------------------------------------------*\
77  Class Matrix Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 template<class Form, class Type>
81 class Matrix
82 {
83  // Private Data
84 
85  //- Number of rows and columns in Matrix
86  label mRows_, nCols_;
87 
88  //- Vector of values of type Type
89  Type* __restrict__ v_;
90 
91 
92  // Private Member Functions
93 
94  //- Allocate storage for the contents
95  inline void doAlloc();
96 
97  //- Right-multiply Matrix by a column vector (A * x)
98  template<class ListType>
99  tmp<Field<Type>> AmulImpl(const ListType& x) const;
100 
101  //- Left-multiply Matrix by a row vector (x * A)
102  template<class ListType>
103  tmp<Field<Type>> TmulImpl(const ListType& x) const;
104 
105 
106 public:
107 
108  //- Matrix type
109  typedef Matrix<Form, Type> mType;
110 
111  //- Component type
112  typedef Type cmptType;
113 
114 
115  // Static Member Functions
117  //- Return a null Matrix (reference to a nullObject).
118  //- Behaves like a empty Matrix.
119  static const Matrix<Form, Type>& null() noexcept
120  {
121  return NullObjectRef<Matrix<Form, Type>>();
122  }
123 
124 
125  // Iterators
126 
127  //- Random access iterator for traversing a Matrix
128  typedef Type* iterator;
129 
130  //- Random access iterator for traversing a Matrix
131  typedef const Type* const_iterator;
132 
133 
134  // Constructors
135 
136  //- Default construct (empty matrix)
137  inline Matrix() noexcept;
138 
139  //- Construct given number of rows/columns, uninitialised content
140  Matrix(const label m, const label n);
142  //- Construct with given number of rows/columns
143  //- initializing all elements to zero
144  Matrix(const label m, const label n, const Foam::zero);
145 
146  //- Construct with given number of rows/columns
147  //- initializing all elements to the given value
148  Matrix(const label m, const label n, const Type& val);
149 
150  //- Construct given number of rows/columns
151  inline explicit Matrix(const labelPair& dims);
152 
153  //- Construct given number of rows/columns
154  //- initializing all elements to zero
155  inline Matrix(const labelPair& dims, const Foam::zero);
156 
157  //- Construct with given number of rows/columns
158  //- initializing all elements to the given value
159  inline Matrix(const labelPair& dims, const Type& val);
160 
161  //- Copy construct
162  Matrix(const Matrix<Form, Type>& mat);
163 
164  //- Move construct
165  Matrix(Matrix<Form, Type>&& mat);
166 
167  //- Copy constructor from Matrix of a different form
168  template<class Form2>
169  explicit Matrix(const Matrix<Form2, Type>& mat);
170 
171  //- Construct from a block of another Matrix
172  template<class MatrixType>
173  Matrix(const ConstMatrixBlock<MatrixType>& Mb);
174 
175  //- Construct from a block of another Matrix
176  template<class MatrixType>
177  Matrix(const MatrixBlock<MatrixType>& Mb);
178 
179  //- Construct from Istream.
180  explicit Matrix(Istream& is);
181 
182  //- Clone
183  inline autoPtr<mType> clone() const;
184 
185 
186  //- Destructor
187  ~Matrix();
188 
189 
190  // Member Functions
191 
192  // Access
193 
194  //- The number of rows
195  label mRows() const noexcept { return mRows_; }
196 
197  //- The number of rows
198  label nRows() const noexcept { return mRows_; }
199 
200  //- The number of rows
201  label m() const noexcept { return mRows_; }
202 
203  //- The number of columns
204  label nCols() const noexcept { return nCols_; }
205 
206  //- The number of columns
207  label n() const noexcept { return nCols_; }
208 
209  //- Return true if Matrix is empty (i.e., size() is zero)
210  inline bool empty() const noexcept;
211 
212  //- The number of elements in Matrix (m*n)
213  inline label size() const;
214 
215  //- Return row/column sizes
216  inline labelPair sizes() const;
217 
218  //- Return const pointer to the first data element, which can also
219  //- be used to address into Matrix contents
220  inline const Type* cdata() const noexcept;
221 
222  //- Return pointer to the first data element, which can also
223  //- be used to address into Matrix contents
224  inline Type* data() noexcept;
225 
226  //- Return pointer to the underlying array serving as data storage,
227  //- reinterpreted as byte data.
228  // \note Only meaningful for contiguous data
229  inline const char* cdata_bytes() const noexcept;
230 
231  //- Return pointer to the underlying array serving as data storage,
232  //- reinterpreted as byte data.
233  // \note Only meaningful for contiguous data
234  inline char* data_bytes() noexcept;
235 
236  //- Number of contiguous bytes for the Matrix data,
237  //- no runtime check that the type is actually contiguous
238  // \note Only meaningful for contiguous data
239  inline std::streamsize size_bytes() const noexcept;
240 
241  //- Number of contiguous bytes for the Matrix data,
242  //- runtime FatalError if type is not contiguous
243  std::streamsize byteSize() const;
244 
245  //- Return const pointer to data in the specified row
246  // Subscript checking only with FULLDEBUG
247  inline const Type* rowData(const label irow) const;
248 
249  //- Return pointer to data in the specified row
250  // Subscript checking only with FULLDEBUG
251  inline Type* rowData(const label irow);
253  //- Linear addressing const element access
254  // Subscript checking only with FULLDEBUG
255  inline const Type& at(const label idx) const;
256 
257  //- Linear addressing element access
258  // Subscript checking only with FULLDEBUG
259  inline Type& at(const label idx);
260 
261  // Block Access (const)
263  //- Return const column or column's subset of Matrix
264  // Return entire column by its index: M.subColumn(a);
265  // Return subset of a column starting from rowIndex: M.subColumn(a, b);
266  // Return subset of a column starting from rowIndex with szRows elems:
267  // M.subColumn(a, b, c);
269  (
270  const label colIndex,
271  const label rowIndex = 0,
272  label len = -1
273  ) const;
274 
275  //- Return const row or const row's subset of Matrix
276  // Return entire row by its index: M.subRow(a);
277  // Return subset of a row starting from columnIndex: M.subRow(a,b);
278  // Return subset of a row starting from columnIndex with szCols elems:
279  // M.subRow(a, b, c);
281  (
282  const label rowIndex,
283  const label colIndex = 0,
284  label len = -1
285  ) const;
286 
287  //- Return const sub-block of Matrix
288  // Sub-block starting at columnIndex & rowIndex indices
290  (
291  const label rowIndex,
292  const label colIndex,
293  label szRows = -1,
294  label szCols = -1
295  ) const;
296 
297  //- Access Field as a ConstMatrixBlock
298  template<class VectorSpace>
300  (
301  const label rowIndex,
302  const label colIndex
303  ) const;
304 
305  // Block Access (non-const)
306 
307  //- Return column or column's subset of Matrix
308  inline MatrixBlock<mType> subColumn
309  (
310  const label colIndex,
311  const label rowIndex = 0,
312  label len = -1
313  );
314 
315  //- Return row or row's subset of Matrix
316  inline MatrixBlock<mType> subRow
317  (
318  const label rowIndex,
319  const label colIndex = 0,
320  label len = -1
321  );
322 
323  //- Return sub-block of Matrix
324  inline MatrixBlock<mType> subMatrix
325  (
326  const label rowIndex,
327  const label colIndex,
328  label szRows = -1,
329  label szCols = -1
330  );
331 
332  //- Access Field as a MatrixBlock
333  template<class VectorSpace>
334  inline MatrixBlock<mType> block
335  (
336  const label rowIndex,
337  const label colIndex
338  );
339 
340  // Check
341 
342  //- Check index i is within valid range [0, m)
343  inline void checki(const label irow) const;
344 
345  //- Check index j is within valid range [0, n)
346  inline void checkj(const label jcol) const;
347 
348  //- Check that dimensions are positive, non-zero
349  inline void checkSize() const;
350 
351  //- True if all entries have identical values, and Matrix is non-empty
352  inline bool uniform() const;
353 
354  // Edit
355 
356  //- Clear Matrix, i.e. set sizes to zero
357  void clear();
358 
359  //- Release storage management of Matrix contents by transferring
360  //- management to a List
361  List<Type> release();
362 
363  //- Swap contents
364  void swap(Matrix<Form, Type>& mat);
365 
366  //- Transfer the contents of the argument Matrix into this Matrix
367  //- and annul the argument Matrix
368  void transfer(Matrix<Form, Type>& mat);
369 
370  //- Change Matrix dimensions, preserving the elements
371  void resize(const label m, const label n);
372 
373  //- Change Matrix dimensions \em without preserving existing content
374  void resize_nocopy(const label mrow, const label ncol);
375 
376  //- Change Matrix dimensions, preserving the elements
377  inline void setSize(const label m, const label n);
378 
379  //- Resize Matrix without reallocating storage (unsafe)
380  inline void shallowResize(const label m, const label n);
381 
382  //- Round elements with magnitude smaller than tol (SMALL) to zero
383  void round(const scalar tol = SMALL);
384 
385 
386  // Operations
387 
388  //- Return conjugate transpose of Matrix
389  Form T() const;
390 
391  //- Return non-conjugate transpose of Matrix
392  Form transpose() const;
393 
394  //- Right-multiply Matrix by a column vector (A * x)
395  inline tmp<Field<Type>> Amul(const UList<Type>& x) const;
396 
397  //- Right-multiply Matrix by a column vector (A * x)
398  template<class Addr>
399  inline tmp<Field<Type>> Amul
400  (
401  const IndirectListBase<Type, Addr>& x
402  ) const;
403 
404  //- Left-multiply Matrix by a row vector (x * A)
405  inline tmp<Field<Type>> Tmul(const UList<Type>& x) const;
406 
407  //- Left-multiply Matrix by a row vector (x * A)
408  template<class Addr>
409  inline tmp<Field<Type>> Tmul
410  (
411  const IndirectListBase<Type, Addr>& x
412  ) const;
413 
414  //- Extract the diagonal elements. Method may change in the future.
415  List<Type> diag() const;
416 
417  //- Assign diagonal of Matrix
418  void diag(const UList<Type>& list);
419 
420  //- Return the trace
421  Type trace() const;
422 
423  //- Return L2-Norm of chosen column
424  // Optional without sqrt for parallel usage.
425  scalar columnNorm(const label colIndex, const bool noSqrt=false) const;
426 
427  //- Return Frobenius norm of Matrix
428  // Optional without sqrt for parallel usage.
429  scalar norm(const bool noSqrt=false) const;
430 
431 
432  // Member Operators
433 
434  //- Return const pointer to data in the specified row - rowData().
435  // Subscript checking only with FULLDEBUG
436  inline const Type* operator[](const label irow) const;
437 
438  //- Return pointer to data in the specified row - rowData().
439  // Subscript checking only with FULLDEBUG
440  inline Type* operator[](const label irow);
441 
442  //- (i, j) const element access operator
443  // Subscript checking only with FULLDEBUG
444  inline const Type& operator()(const label irow, const label jcol) const;
445 
446  //- (i, j) element access operator
447  // Subscript checking only with FULLDEBUG
448  inline Type& operator()(const label irow, const label jcol);
449 
450  //- Copy assignment. Takes linear time.
451  void operator=(const Matrix<Form, Type>& mat);
452 
453  //- Move assignment
454  void operator=(Matrix<Form, Type>&& mat);
455 
456  //- Assignment to a block of another Matrix
457  template<class MatrixType>
458  void operator=(const ConstMatrixBlock<MatrixType>& Mb);
459 
460  //- Assignment to a block of another Matrix
461  template<class MatrixType>
462  void operator=(const MatrixBlock<MatrixType>& Mb);
463 
464  //- Assignment of all elements to zero
465  void operator=(const Foam::zero);
466 
467  //- Assignment of all elements to the given value
468  void operator=(const Type& val);
469 
470  //- Matrix addition
471  void operator+=(const Matrix<Form, Type>& other);
472 
473  //- Matrix subtraction
474  void operator-=(const Matrix<Form, Type>& other);
475 
476  //- Matrix scalar addition
477  void operator+=(const Type& s);
478 
479  //- Matrix scalar subtraction
480  void operator-=(const Type& s);
481 
482  //- Matrix scalar multiplication
483  void operator*=(const Type& s);
484 
485  //- Matrix scalar division
486  void operator/=(const Type& s);
487 
488 
489  // Random Access Iterator (non-const)
490 
491  //- Return an iterator to begin traversing a Matrix
492  inline iterator begin() noexcept;
493 
494  //- Return an iterator to end traversing a Matrix
495  inline iterator end() noexcept;
496 
497 
498  // Random Access Iterator (const)
499 
500  //- Return const_iterator to begin traversing a constant Matrix
501  inline const_iterator cbegin() const noexcept;
502 
503  //- Return const_iterator to end traversing a constant Matrix
504  inline const_iterator cend() const noexcept;
505 
506  //- Return const_iterator to begin traversing a constant Matrix
507  inline const_iterator begin() const noexcept;
508 
509  //- Return const_iterator to end traversing a constant Matrix
510  inline const_iterator end() const noexcept;
511 
512 
513  // IO
514 
515  //- Read Matrix from Istream, discarding existing contents.
516  bool readMatrix(Istream& is);
517 
518  //- Write Matrix, with line-breaks in ASCII when length exceeds
519  //- shortLen.
520  // Using '0' suppresses line-breaks entirely.
521  Ostream& writeMatrix(Ostream& os, const label shortLen=0) const;
522 
523 
524  // Housekeeping
525 
526  //- Deprecated(2019-04) raw data pointer, const access
527  // \deprecated(2019-04) - use cdata() method
528  FOAM_DEPRECATED_FOR(2019-04, "cdata() method")
529  const Type* v() const
530  {
531  return v_;
532  }
533 
534  //- Deprecated(2019-04) raw data pointer, non-const access
535  // \deprecated(2019-04) - use data() method
536  FOAM_DEPRECATED_FOR(2019-04, "data() method")
537  Type* v()
538  {
539  return v_;
540  }
541 
542  //- Deprecated(2019-04) - use subMatrix()
543  // \deprecated(2019-04) - use subMatrix()
544  FOAM_DEPRECATED_FOR(2019-04, "subMatrix() method")
545  ConstMatrixBlock<mType> block
546  (
547  const label m,
548  const label n,
549  const label mStart,
550  const label nStart
551  ) const
552  {
553  return this->subMatrix(mStart, nStart, m, n);
554  }
555 
556  //- Deprecated(2019-04) - use subMatrix()
557  // \deprecated(2019-04) - use subMatrix()
558  FOAM_DEPRECATED_FOR(2019-04, "subMatrix() method")
559  MatrixBlock<mType> block
560  (
561  const label m,
562  const label n,
563  const label mStart,
564  const label nStart
565  )
566  {
567  return this->subMatrix(mStart, nStart, m, n);
568  }
569 
570 
571  //- Deprecated(2019-04) - use subColumn()
572  // \deprecated(2019-04) - use subColumn()
573  FOAM_DEPRECATED_FOR(2019-04, "subColumn() method")
574  ConstMatrixBlock<mType> col
575  (
576  const label m,
577  const label mStart,
578  const label nStart
579  ) const
580  {
581  return this->subColumn(nStart, mStart, m);
582  }
583 
584  //- Deprecated(2019-04) - use subColumn()
585  // \deprecated(2019-04) - use subColumn()
586  FOAM_DEPRECATED_FOR(2019-04, "subColumn() method")
587  MatrixBlock<mType> col
588  (
589  const label m,
590  const label mStart,
591  const label nStart
592  )
593  {
594  return this->subColumn(nStart, mStart, m);
595  }
596 
597  //- Deleted(2019-04) - use subColumn()
598  // \deprecated(2019-04) - use subColumn()
599  void col(const label m, const label rowStart) const = delete;
600 
601  //- Deleted(2019-04) - use subColumn()
602  // \deprecated(2019-04) - use subColumn()
603  void col(const label m, const label rowStart) = delete;
604 };
605 
606 
607 // * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
608 
609 //- Read Matrix from Istream, discarding contents of existing Matrix.
610 template<class Form, class Type>
611 Istream& operator>>(Istream& is, Matrix<Form, Type>& mat)
612 {
613  mat.readMatrix(is);
614  return is;
615 }
616 
617 
618 //- Write Matrix to Ostream, as per Matrix::writeMatrix() with
619 //- default length, which is given by Detail::ListPolicy::short_length
620 template<class Form, class Type>
621 Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat)
622 {
623  return mat.writeMatrix(os, Detail::ListPolicy::short_length<Type>::value);
624 }
625 
626 
627 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
628 
629 } // End namespace Foam
630 
631 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
632 
633 #include "MatrixI.H"
634 
635 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
636 
637 #ifdef NoRepository
638  #include "Matrix.C"
639  #include "MatrixIO.C"
640 #endif
641 
642 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
643 
644 #endif
645 
646 // ************************************************************************* //
void shallowResize(const label m, const label n)
Resize Matrix without reallocating storage (unsafe)
Definition: MatrixI.H:455
void resize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
Definition: Matrix.C:315
ConstMatrixBlock< mType > subColumn(const label colIndex, const label rowIndex=0, label len=-1) const
Return const column or column&#39;s subset of Matrix.
Definition: MatrixI.H:262
ConstMatrixBlock< mType > subRow(const label rowIndex, const label colIndex=0, label len=-1) const
Return const row or const row&#39;s subset of Matrix.
Definition: MatrixI.H:287
autoPtr< mType > clone() const
Clone.
Definition: MatrixI.H:73
tmp< Field< Type > > Tmul(const UList< Type > &x) const
Left-multiply Matrix by a row vector (x * A)
Definition: MatrixI.H:485
Form T() const
Return conjugate transpose of Matrix.
Definition: Matrix.C:383
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
tmp< Field< Type > > Amul(const UList< Type > &x) const
Right-multiply Matrix by a column vector (A * x)
Definition: MatrixI.H:464
scalar columnNorm(const label colIndex, const bool noSqrt=false) const
Return L2-Norm of chosen column.
Definition: Matrix.C:471
Templated vector space.
Definition: VectorSpace.H:52
A templated block of an (m x n) matrix of type <MatrixType>.
Definition: Matrix.H:62
void setSize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
Definition: MatrixI.H:448
List< Type > release()
Release storage management of Matrix contents by transferring management to a List.
Definition: Matrix.C:261
iterator begin() noexcept
Return an iterator to begin traversing a Matrix.
Definition: MatrixI.H:508
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
void transfer(Matrix< Form, Type > &mat)
Transfer the contents of the argument Matrix into this Matrix and annul the argument Matrix...
Definition: Matrix.C:295
bool empty() const noexcept
Return true if Matrix is empty (i.e., size() is zero)
Definition: MatrixI.H:96
bool readMatrix(Istream &is)
Read Matrix from Istream, discarding existing contents.
Definition: MatrixIO.C:45
ConstMatrixBlock< mType > subMatrix(const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) const
Return const sub-block of Matrix.
Definition: MatrixI.H:312
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:65
label nCols() const noexcept
The number of columns.
Definition: Matrix.H:257
label n() const noexcept
The number of columns.
Definition: Matrix.H:262
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage, reinterpreted as byte data...
Definition: MatrixI.H:196
Ostream & writeMatrix(Ostream &os, const label shortLen=0) const
Write Matrix, with line-breaks in ASCII when length exceeds shortLen.
Definition: MatrixIO.C:135
label size() const
The number of elements in Matrix (m*n)
Definition: MatrixI.H:82
Type trace() const
Return the trace.
Definition: Matrix.C:454
Generic templated field type.
Definition: Field.H:62
const Type & at(const label idx) const
Linear addressing const element access.
Definition: MatrixI.H:230
List< Type > diag() const
Extract the diagonal elements. Method may change in the future.
Definition: Matrix.C:417
Type * iterator
Random access iterator for traversing a Matrix.
Definition: Matrix.H:141
label nRows() const noexcept
The number of rows.
Definition: Matrix.H:247
labelPair sizes() const
Return row/column sizes.
Definition: MatrixI.H:89
Istream & operator>>(Istream &, directionInfo &)
iterator end() noexcept
Return an iterator to end traversing a Matrix.
Definition: MatrixI.H:516
scalar norm(const bool noSqrt=false) const
Return Frobenius norm of Matrix.
Definition: Matrix.C:488
void clear()
Clear Matrix, i.e. set sizes to zero.
Definition: Matrix.C:247
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:105
const Type * cdata() const noexcept
Return const pointer to the first data element, which can also be used to address into Matrix content...
Definition: MatrixI.H:175
void checki(const label irow) const
Check index i is within valid range [0, m)
Definition: MatrixI.H:103
void swap(Matrix< Form, Type > &mat)
Swap contents.
Definition: Matrix.C:281
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order: ...
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:54
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
Type cmptType
Component type.
Definition: Matrix.H:121
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the Matrix data, no runtime check that the type is actually contiguous...
Definition: MatrixI.H:203
Pair< label > labelPair
A pair of labels.
Definition: Pair.H:51
OBJstream os(runTime.globalPath()/outputName)
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage, reinterpreted as byte data...
Definition: MatrixI.H:189
label m() const noexcept
The number of rows.
Definition: Matrix.H:252
const Type * const_iterator
Random access iterator for traversing a Matrix.
Definition: Matrix.H:146
std::streamsize byteSize() const
Number of contiguous bytes for the Matrix data, runtime FatalError if type is not contiguous...
Definition: Matrix.C:502
const Type * v() const
Deprecated(2019-04) raw data pointer, const access.
Definition: Matrix.H:742
const_iterator cend() const noexcept
Return const_iterator to end traversing a constant Matrix.
Definition: MatrixI.H:532
const Type * rowData(const label irow) const
Return const pointer to data in the specified row.
Definition: MatrixI.H:210
label mRows() const noexcept
The number of rows.
Definition: Matrix.H:242
Matrix< Form, Type > mType
Matrix type.
Definition: Matrix.H:116
static const Matrix< Form, Type > & null() noexcept
Return a null Matrix (reference to a nullObject). Behaves like a empty Matrix.
Definition: Matrix.H:130
Form transpose() const
Return non-conjugate transpose of Matrix.
Definition: Matrix.C:400
void checkj(const label jcol) const
Check index j is within valid range [0, n)
Definition: MatrixI.H:121
Matrix() noexcept
Default construct (empty matrix)
Definition: MatrixI.H:42
Type * data() noexcept
Return pointer to the first data element, which can also be used to address into Matrix contents...
Definition: MatrixI.H:182
void round(const scalar tol=SMALL)
Round elements with magnitude smaller than tol (SMALL) to zero.
Definition: Matrix.C:370
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing a constant Matrix.
Definition: MatrixI.H:524
void resize_nocopy(const label mrow, const label ncol)
Change Matrix dimensions without preserving existing content.
Definition: Matrix.C:340
A class for managing temporary objects.
Definition: HashPtrTable.H:50
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
ConstMatrixBlock< mType > col(const label m, const label mStart, const label nStart) const
Deprecated(2019-04) - use subColumn()
Definition: Matrix.H:800
ConstMatrixBlock< mType > block(const label rowIndex, const label colIndex) const
Access Field as a ConstMatrixBlock.
Namespace for OpenFOAM.
void checkSize() const
Check that dimensions are positive, non-zero.
Definition: MatrixI.H:139