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
118  inline static const Matrix<Form, Type>& null();
119 
120 
121  // Iterators
122 
123  //- Random access iterator for traversing a Matrix
124  typedef Type* iterator;
125 
126  //- Random access iterator for traversing a Matrix
127  typedef const Type* const_iterator;
128 
129 
130  // Constructors
131 
132  //- Default construct (empty matrix)
133  inline Matrix() noexcept;
134 
135  //- Construct given number of rows/columns
136  Matrix(const label m, const label n);
138  //- Construct with given number of rows/columns
139  //- initializing all elements to zero
140  Matrix(const label m, const label n, const Foam::zero);
141 
142  //- Construct with given number of rows/columns
143  //- initializing all elements to the given value
144  Matrix(const label m, const label n, const Type& val);
145 
146  //- Construct given number of rows/columns
147  inline explicit Matrix(const labelPair& dims);
148 
149  //- Construct given number of rows/columns
150  //- initializing all elements to zero
151  inline Matrix(const labelPair& dims, const Foam::zero);
152 
153  //- Construct with given number of rows/columns
154  //- initializing all elements to the given value
155  inline Matrix(const labelPair& dims, const Type& val);
156 
157  //- Copy construct
158  Matrix(const Matrix<Form, Type>& mat);
159 
160  //- Move construct
161  Matrix(Matrix<Form, Type>&& mat);
162 
163  //- Copy constructor from Matrix of a different form
164  template<class Form2>
165  explicit Matrix(const Matrix<Form2, Type>& mat);
166 
167  //- Construct from a block of another Matrix
168  template<class MatrixType>
169  Matrix(const ConstMatrixBlock<MatrixType>& Mb);
170 
171  //- Construct from a block of another Matrix
172  template<class MatrixType>
173  Matrix(const MatrixBlock<MatrixType>& Mb);
174 
175  //- Construct from Istream.
176  explicit Matrix(Istream& is);
177 
178  //- Clone
179  inline autoPtr<mType> clone() const;
180 
181 
182  //- Destructor
183  ~Matrix();
184 
185 
186  // Member Functions
187 
188  // Access
189 
190  //- The number of rows
191  label mRows() const noexcept { return mRows_; }
192 
193  //- The number of rows
194  label nRows() const noexcept { return mRows_; }
195 
196  //- The number of rows
197  label m() const noexcept { return mRows_; }
198 
199  //- The number of columns
200  label nCols() const noexcept { return nCols_; }
201 
202  //- The number of columns
203  label n() const noexcept { return nCols_; }
204 
205  //- Return true if Matrix is empty (i.e., size() is zero)
206  inline bool empty() const noexcept;
207 
208  //- The number of elements in Matrix (m*n)
209  inline label size() const;
210 
211  //- Return row/column sizes
212  inline labelPair sizes() const;
213 
214  //- Return const pointer to the first data element, which can also
215  //- be used to address into Matrix contents
216  inline const Type* cdata() const noexcept;
217 
218  //- Return pointer to the first data element, which can also
219  //- be used to address into Matrix contents
220  inline Type* data() noexcept;
221 
222  //- Return pointer to the underlying array serving as data storage,
223  //- reinterpreted as byte data.
224  // \note Only meaningful for contiguous data
225  inline const char* cdata_bytes() const noexcept;
226 
227  //- Return pointer to the underlying array serving as data storage,
228  //- reinterpreted as byte data.
229  // \note Only meaningful for contiguous data
230  inline char* data_bytes() noexcept;
231 
232  //- Number of contiguous bytes for the Matrix data,
233  //- no runtime check that the type is actually contiguous
234  // \note Only meaningful for contiguous data
235  inline std::streamsize size_bytes() const noexcept;
236 
237  //- Number of contiguous bytes for the Matrix data,
238  //- runtime FatalError if type is not contiguous
239  std::streamsize byteSize() const;
240 
241  //- Return const pointer to data in the specified row
242  // Subscript checking only with FULLDEBUG
243  inline const Type* rowData(const label irow) const;
244 
245  //- Return pointer to data in the specified row
246  // Subscript checking only with FULLDEBUG
247  inline Type* rowData(const label irow);
249  //- Linear addressing const element access
250  // Subscript checking only with FULLDEBUG
251  inline const Type& at(const label idx) const;
252 
253  //- Linear addressing element access
254  // Subscript checking only with FULLDEBUG
255  inline Type& at(const label idx);
256 
257  // Block Access (const)
259  //- Return const column or column's subset of Matrix
260  // Return entire column by its index: M.subColumn(a);
261  // Return subset of a column starting from rowIndex: M.subColumn(a, b);
262  // Return subset of a column starting from rowIndex with szRows elems:
263  // M.subColumn(a, b, c);
265  (
266  const label colIndex,
267  const label rowIndex = 0,
268  label len = -1
269  ) const;
270 
271  //- Return const row or const row's subset of Matrix
272  // Return entire row by its index: M.subRow(a);
273  // Return subset of a row starting from columnIndex: M.subRow(a,b);
274  // Return subset of a row starting from columnIndex with szCols elems:
275  // M.subRow(a, b, c);
277  (
278  const label rowIndex,
279  const label colIndex = 0,
280  label len = -1
281  ) const;
282 
283  //- Return const sub-block of Matrix
284  // Sub-block starting at columnIndex & rowIndex indices
286  (
287  const label rowIndex,
288  const label colIndex,
289  label szRows = -1,
290  label szCols = -1
291  ) const;
292 
293  //- Access Field as a ConstMatrixBlock
294  template<class VectorSpace>
296  (
297  const label rowIndex,
298  const label colIndex
299  ) const;
300 
301  // Block Access (non-const)
302 
303  //- Return column or column's subset of Matrix
304  inline MatrixBlock<mType> subColumn
305  (
306  const label colIndex,
307  const label rowIndex = 0,
308  label len = -1
309  );
310 
311  //- Return row or row's subset of Matrix
312  inline MatrixBlock<mType> subRow
313  (
314  const label rowIndex,
315  const label colIndex = 0,
316  label len = -1
317  );
318 
319  //- Return sub-block of Matrix
320  inline MatrixBlock<mType> subMatrix
321  (
322  const label rowIndex,
323  const label colIndex,
324  label szRows = -1,
325  label szCols = -1
326  );
327 
328  //- Access Field as a MatrixBlock
329  template<class VectorSpace>
330  inline MatrixBlock<mType> block
331  (
332  const label rowIndex,
333  const label colIndex
334  );
335 
336  // Check
337 
338  //- Check index i is within valid range [0, m)
339  inline void checki(const label irow) const;
340 
341  //- Check index j is within valid range [0, n)
342  inline void checkj(const label jcol) const;
343 
344  //- Check that dimensions are positive, non-zero
345  inline void checkSize() const;
346 
347  //- True if all entries have identical values, and Matrix is non-empty
348  inline bool uniform() const;
349 
350  // Edit
351 
352  //- Clear Matrix, i.e. set sizes to zero
353  void clear();
354 
355  //- Release storage management of Matrix contents by transferring
356  //- management to a List
357  List<Type> release();
358 
359  //- Swap contents
360  void swap(Matrix<Form, Type>& mat);
361 
362  //- Transfer the contents of the argument Matrix into this Matrix
363  //- and annul the argument Matrix
364  void transfer(Matrix<Form, Type>& mat);
365 
366  //- Change Matrix dimensions, preserving the elements
367  void resize(const label m, const label n);
368 
369  //- Change Matrix dimensions \em without preserving existing content
370  void resize_nocopy(const label mrow, const label ncol);
371 
372  //- Change Matrix dimensions, preserving the elements
373  inline void setSize(const label m, const label n);
374 
375  //- Resize Matrix without reallocating storage (unsafe)
376  inline void shallowResize(const label m, const label n);
377 
378  //- Round elements with magnitude smaller than tol (SMALL) to zero
379  void round(const scalar tol = SMALL);
380 
381 
382  // Operations
383 
384  //- Return conjugate transpose of Matrix
385  Form T() const;
386 
387  //- Return non-conjugate transpose of Matrix
388  Form transpose() const;
389 
390  //- Right-multiply Matrix by a column vector (A * x)
391  inline tmp<Field<Type>> Amul(const UList<Type>& x) const;
392 
393  //- Right-multiply Matrix by a column vector (A * x)
394  template<class Addr>
395  inline tmp<Field<Type>> Amul
396  (
397  const IndirectListBase<Type, Addr>& x
398  ) const;
399 
400  //- Left-multiply Matrix by a row vector (x * A)
401  inline tmp<Field<Type>> Tmul(const UList<Type>& x) const;
402 
403  //- Left-multiply Matrix by a row vector (x * A)
404  template<class Addr>
405  inline tmp<Field<Type>> Tmul
406  (
407  const IndirectListBase<Type, Addr>& x
408  ) const;
409 
410  //- Extract the diagonal elements. Method may change in the future.
411  List<Type> diag() const;
412 
413  //- Assign diagonal of Matrix
414  void diag(const UList<Type>& list);
415 
416  //- Return the trace
417  Type trace() const;
418 
419  //- Return L2-Norm of chosen column
420  // Optional without sqrt for parallel usage.
421  scalar columnNorm(const label colIndex, const bool noSqrt=false) const;
422 
423  //- Return Frobenius norm of Matrix
424  // Optional without sqrt for parallel usage.
425  scalar norm(const bool noSqrt=false) const;
426 
427 
428  // Member Operators
429 
430  //- Return const pointer to data in the specified row - rowData().
431  // Subscript checking only with FULLDEBUG
432  inline const Type* operator[](const label irow) const;
433 
434  //- Return pointer to data in the specified row - rowData().
435  // Subscript checking only with FULLDEBUG
436  inline Type* operator[](const label irow);
437 
438  //- (i, j) const element access operator
439  // Subscript checking only with FULLDEBUG
440  inline const Type& operator()(const label irow, const label jcol) const;
441 
442  //- (i, j) element access operator
443  // Subscript checking only with FULLDEBUG
444  inline Type& operator()(const label irow, const label jcol);
445 
446  //- Copy assignment. Takes linear time.
447  void operator=(const Matrix<Form, Type>& mat);
448 
449  //- Move assignment
450  void operator=(Matrix<Form, Type>&& mat);
451 
452  //- Assignment to a block of another Matrix
453  template<class MatrixType>
454  void operator=(const ConstMatrixBlock<MatrixType>& Mb);
455 
456  //- Assignment to a block of another Matrix
457  template<class MatrixType>
458  void operator=(const MatrixBlock<MatrixType>& Mb);
459 
460  //- Assignment of all elements to zero
461  void operator=(const Foam::zero);
462 
463  //- Assignment of all elements to the given value
464  void operator=(const Type& val);
465 
466  //- Matrix addition
467  void operator+=(const Matrix<Form, Type>& other);
468 
469  //- Matrix subtraction
470  void operator-=(const Matrix<Form, Type>& other);
471 
472  //- Matrix scalar addition
473  void operator+=(const Type& s);
474 
475  //- Matrix scalar subtraction
476  void operator-=(const Type& s);
477 
478  //- Matrix scalar multiplication
479  void operator*=(const Type& s);
480 
481  //- Matrix scalar division
482  void operator/=(const Type& s);
483 
484 
485  // Random Access Iterator (non-const)
486 
487  //- Return an iterator to begin traversing a Matrix
488  inline iterator begin() noexcept;
489 
490  //- Return an iterator to end traversing a Matrix
491  inline iterator end() noexcept;
492 
493 
494  // Random Access Iterator (const)
495 
496  //- Return const_iterator to begin traversing a constant Matrix
497  inline const_iterator cbegin() const noexcept;
498 
499  //- Return const_iterator to end traversing a constant Matrix
500  inline const_iterator cend() const noexcept;
501 
502  //- Return const_iterator to begin traversing a constant Matrix
503  inline const_iterator begin() const noexcept;
504 
505  //- Return const_iterator to end traversing a constant Matrix
506  inline const_iterator end() const noexcept;
507 
508 
509  // IO
510 
511  //- Read Matrix from Istream, discarding existing contents.
512  bool readMatrix(Istream& is);
513 
514  //- Write Matrix, with line-breaks in ASCII when length exceeds
515  //- shortLen.
516  // Using '0' suppresses line-breaks entirely.
517  Ostream& writeMatrix(Ostream& os, const label shortLen=0) const;
518 
519 
520  // Housekeeping
521 
522  //- Deprecated(2019-04) raw data pointer, const access
523  // \deprecated(2019-04) - use cdata() method
524  FOAM_DEPRECATED_FOR(2019-04, "cdata() method")
525  const Type* v() const
526  {
527  return v_;
528  }
529 
530  //- Deprecated(2019-04) raw data pointer, non-const access
531  // \deprecated(2019-04) - use data() method
532  FOAM_DEPRECATED_FOR(2019-04, "data() method")
533  Type* v()
534  {
535  return v_;
536  }
537 
538  //- Deprecated(2019-04) - use subMatrix()
539  // \deprecated(2019-04) - use subMatrix()
540  FOAM_DEPRECATED_FOR(2019-04, "subMatrix() method")
541  ConstMatrixBlock<mType> block
542  (
543  const label m,
544  const label n,
545  const label mStart,
546  const label nStart
547  ) const
548  {
549  return this->subMatrix(mStart, nStart, m, n);
550  }
551 
552  //- Deprecated(2019-04) - use subMatrix()
553  // \deprecated(2019-04) - use subMatrix()
554  FOAM_DEPRECATED_FOR(2019-04, "subMatrix() method")
555  MatrixBlock<mType> block
556  (
557  const label m,
558  const label n,
559  const label mStart,
560  const label nStart
561  )
562  {
563  return this->subMatrix(mStart, nStart, m, n);
564  }
565 
566 
567  //- Deprecated(2019-04) - use subColumn()
568  // \deprecated(2019-04) - use subColumn()
569  FOAM_DEPRECATED_FOR(2019-04, "subColumn() method")
570  ConstMatrixBlock<mType> col
571  (
572  const label m,
573  const label mStart,
574  const label nStart
575  ) const
576  {
577  return this->subColumn(nStart, mStart, m);
578  }
579 
580  //- Deprecated(2019-04) - use subColumn()
581  // \deprecated(2019-04) - use subColumn()
582  FOAM_DEPRECATED_FOR(2019-04, "subColumn() method")
583  MatrixBlock<mType> col
584  (
585  const label m,
586  const label mStart,
587  const label nStart
588  )
589  {
590  return this->subColumn(nStart, mStart, m);
591  }
592 
593  //- Deleted(2019-04) - use subColumn()
594  // \deprecated(2019-04) - use subColumn()
595  void col(const label m, const label rowStart) const = delete;
596 
597  //- Deleted(2019-04) - use subColumn()
598  // \deprecated(2019-04) - use subColumn()
599  void col(const label m, const label rowStart) = delete;
600 };
601 
602 
603 // * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
604 
605 //- Read Matrix from Istream, discarding contents of existing Matrix.
606 template<class Form, class Type>
607 Istream& operator>>(Istream& is, Matrix<Form, Type>& mat)
608 {
609  mat.readMatrix(is);
610  return is;
611 }
612 
613 
614 //- Write Matrix to Ostream, as per Matrix::writeMatrix() with
615 //- default length, which is given by Detail::ListPolicy::short_length
616 template<class Form, class Type>
617 Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat)
618 {
619  return mat.writeMatrix(os, Detail::ListPolicy::short_length<Type>::value);
620 }
621 
622 
623 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
624 
625 } // End namespace Foam
626 
627 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
628 
629 #include "MatrixI.H"
630 
631 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
632 
633 #ifdef NoRepository
634  #include "Matrix.C"
635  #include "MatrixIO.C"
636 #endif
637 
638 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
639 
640 #endif
641 
642 // ************************************************************************* //
void shallowResize(const label m, const label n)
Resize Matrix without reallocating storage (unsafe)
Definition: MatrixI.H:462
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:269
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:294
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:492
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:471
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:455
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:515
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:103
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:319
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:65
label nCols() const noexcept
The number of columns.
Definition: Matrix.H:253
label n() const noexcept
The number of columns.
Definition: Matrix.H:258
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage, reinterpreted as byte data...
Definition: MatrixI.H:203
Ostream & writeMatrix(Ostream &os, const label shortLen=0) const
Write Matrix, with line-breaks in ASCII when length exceeds shortLen.
Definition: MatrixIO.C:135
static const Matrix< Form, Type > & null()
Return a null Matrix.
Definition: MatrixI.H:82
label size() const
The number of elements in Matrix (m*n)
Definition: MatrixI.H:89
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:237
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:137
label nRows() const noexcept
The number of rows.
Definition: Matrix.H:243
labelPair sizes() const
Return row/column sizes.
Definition: MatrixI.H:96
Istream & operator>>(Istream &, directionInfo &)
iterator end() noexcept
Return an iterator to end traversing a Matrix.
Definition: MatrixI.H:523
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:182
void checki(const label irow) const
Check index i is within valid range [0, m)
Definition: MatrixI.H:110
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:210
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:196
label m() const noexcept
The number of rows.
Definition: Matrix.H:248
const Type * const_iterator
Random access iterator for traversing a Matrix.
Definition: Matrix.H:142
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:738
const_iterator cend() const noexcept
Return const_iterator to end traversing a constant Matrix.
Definition: MatrixI.H:539
const Type * rowData(const label irow) const
Return const pointer to data in the specified row.
Definition: MatrixI.H:217
label mRows() const noexcept
The number of rows.
Definition: Matrix.H:238
Matrix< Form, Type > mType
Matrix type.
Definition: Matrix.H:116
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:128
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:189
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:531
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:796
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:146