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-2021 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 Matrix_H
51 #define 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>
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
116 
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);
137 
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  inline label m() const noexcept;
192 
193  //- The number of columns
194  inline label n() const noexcept;
195 
196  //- The number of elements in Matrix (m*n)
197  inline label size() const;
198 
199  //- Return row/column sizes
200  inline labelPair sizes() const;
201 
202  //- Return true if Matrix is empty (i.e., size() is zero)
203  inline bool empty() const noexcept;
204 
205  //- Return const pointer to the first data element, which can also
206  //- be used to address into Matrix contents
207  inline const Type* cdata() const noexcept;
208 
209  //- Return pointer to the first data element, which can also
210  //- be used to address into Matrix contents
211  inline Type* data() noexcept;
212 
213  //- Return pointer to the underlying array serving as data storage,
214  //- reinterpreted as byte data.
215  // \note Only meaningful for contiguous data
216  inline const char* cdata_bytes() const noexcept;
217 
218  //- Return pointer to the underlying array serving as data storage,
219  //- reinterpreted as byte data.
220  // \note Only meaningful for contiguous data
221  inline char* data_bytes() noexcept;
222 
223  //- Number of contiguous bytes for the Matrix data,
224  //- no runtime check that the type is actually contiguous
225  // \note Only meaningful for contiguous data
226  inline std::streamsize size_bytes() const noexcept;
227 
228  //- Number of contiguous bytes for the Matrix data,
229  //- runtime FatalError if type is not contiguous
230  std::streamsize byteSize() const;
231 
232  //- Return const pointer to data in the specified row
233  // Subscript checking only with FULLDEBUG
234  inline const Type* rowData(const label irow) const;
235 
236  //- Return pointer to data in the specified row
237  // Subscript checking only with FULLDEBUG
238  inline Type* rowData(const label irow);
239 
240  //- Linear addressing const element access
241  // Subscript checking only with FULLDEBUG
242  inline const Type& at(const label idx) const;
243 
244  //- Linear addressing element access
245  // Subscript checking only with FULLDEBUG
246  inline Type& at(const label idx);
247 
248  // Block Access (const)
249 
250  //- Return const column or column's subset of Matrix
251  // Return entire column by its index: M.subColumn(a);
252  // Return subset of a column starting from rowIndex: M.subColumn(a, b);
253  // Return subset of a column starting from rowIndex with szRows elems:
254  // M.subColumn(a, b, c);
256  (
257  const label colIndex,
258  const label rowIndex = 0,
259  label len = -1
260  ) const;
261 
262  //- Return const row or const row's subset of Matrix
263  // Return entire row by its index: M.subRow(a);
264  // Return subset of a row starting from columnIndex: M.subRow(a,b);
265  // Return subset of a row starting from columnIndex with szCols elems:
266  // M.subRow(a, b, c);
268  (
269  const label rowIndex,
270  const label colIndex = 0,
271  label len = -1
272  ) const;
273 
274  //- Return const sub-block of Matrix
275  // Sub-block starting at columnIndex & rowIndex indices
277  (
278  const label rowIndex,
279  const label colIndex,
280  label szRows = -1,
281  label szCols = -1
282  ) const;
283 
284  //- Access Field as a ConstMatrixBlock
285  template<class VectorSpace>
287  (
288  const label rowIndex,
289  const label colIndex
290  ) const;
291 
292  // Block Access (non-const)
293 
294  //- Return column or column's subset of Matrix
295  inline MatrixBlock<mType> subColumn
296  (
297  const label colIndex,
298  const label rowIndex = 0,
299  label len = -1
300  );
301 
302  //- Return row or row's subset of Matrix
303  inline MatrixBlock<mType> subRow
304  (
305  const label rowIndex,
306  const label colIndex = 0,
307  label len = -1
308  );
309 
310  //- Return sub-block of Matrix
311  inline MatrixBlock<mType> subMatrix
312  (
313  const label rowIndex,
314  const label colIndex,
315  label szRows = -1,
316  label szCols = -1
317  );
318 
319  //- Access Field as a MatrixBlock
320  template<class VectorSpace>
321  inline MatrixBlock<mType> block
322  (
323  const label rowIndex,
324  const label colIndex
325  );
326 
327  // Check
328 
329  //- Check index i is within valid range [0, m)
330  inline void checki(const label irow) const;
331 
332  //- Check index j is within valid range [0, n)
333  inline void checkj(const label jcol) const;
334 
335  //- Check that dimensions are positive, non-zero
336  inline void checkSize() const;
337 
338  //- True if all entries have identical values, and Matrix is non-empty
339  inline bool uniform() const;
340 
341  // Edit
342 
343  //- Clear Matrix, i.e. set sizes to zero
344  void clear();
345 
346  //- Release storage management of Matrix contents by transferring
347  //- management to a List
348  List<Type> release();
349 
350  //- Swap contents
351  void swap(Matrix<Form, Type>& mat);
352 
353  //- Transfer the contents of the argument Matrix into this Matrix
354  //- and annul the argument Matrix
355  void transfer(Matrix<Form, Type>& mat);
356 
357  //- Change Matrix dimensions, preserving the elements
358  void resize(const label m, const label n);
359 
360  //- Change Matrix dimensions \em without preserving existing content
361  void resize_nocopy(const label mrow, const label ncol);
362 
363  //- Change Matrix dimensions, preserving the elements
364  inline void setSize(const label m, const label n);
365 
366  //- Resize Matrix without reallocating storage (unsafe)
367  inline void shallowResize(const label m, const label n);
368 
369  //- Round elements with magnitude smaller than tol (SMALL) to zero
370  void round(const scalar tol = SMALL);
371 
372 
373  // Operations
374 
375  //- Return (conjugate) transpose of Matrix
376  Form T() const;
377 
378  //- Right-multiply Matrix by a column vector (A * x)
379  inline tmp<Field<Type>> Amul(const UList<Type>& x) const;
380 
381  //- Right-multiply Matrix by a column vector (A * x)
382  template<class Addr>
383  inline tmp<Field<Type>> Amul
384  (
385  const IndirectListBase<Type, Addr>& x
386  ) const;
387 
388  //- Left-multiply Matrix by a row vector (x * A)
389  inline tmp<Field<Type>> Tmul(const UList<Type>& x) const;
390 
391  //- Left-multiply Matrix by a row vector (x * A)
392  template<class Addr>
393  inline tmp<Field<Type>> Tmul
394  (
395  const IndirectListBase<Type, Addr>& x
396  ) const;
397 
398  //- Extract the diagonal elements. Method may change in the future.
399  List<Type> diag() const;
400 
401  //- Assign diagonal of Matrix
402  void diag(const UList<Type>& list);
403 
404  //- Return the trace
405  Type trace() const;
406 
407  //- Return L2-Norm of chosen column
408  // Optional without sqrt for parallel usage.
409  scalar columnNorm(const label colIndex, const bool noSqrt=false) const;
410 
411  //- Return Frobenius norm of Matrix
412  // Optional without sqrt for parallel usage.
413  scalar norm(const bool noSqrt=false) const;
414 
415 
416  // Member Operators
417 
418  //- Return const pointer to data in the specified row - rowData().
419  // Subscript checking only with FULLDEBUG
420  inline const Type* operator[](const label irow) const;
421 
422  //- Return pointer to data in the specified row - rowData().
423  // Subscript checking only with FULLDEBUG
424  inline Type* operator[](const label irow);
425 
426  //- (i, j) const element access operator
427  // Subscript checking only with FULLDEBUG
428  inline const Type& operator()(const label irow, const label jcol) const;
429 
430  //- (i, j) element access operator
431  // Subscript checking only with FULLDEBUG
432  inline Type& operator()(const label irow, const label jcol);
433 
434  //- Copy assignment. Takes linear time.
435  void operator=(const Matrix<Form, Type>& mat);
436 
437  //- Move assignment
438  void operator=(Matrix<Form, Type>&& mat);
439 
440  //- Assignment to a block of another Matrix
441  template<class MatrixType>
442  void operator=(const ConstMatrixBlock<MatrixType>& Mb);
443 
444  //- Assignment to a block of another Matrix
445  template<class MatrixType>
446  void operator=(const MatrixBlock<MatrixType>& Mb);
447 
448  //- Assignment of all elements to zero
449  void operator=(const Foam::zero);
450 
451  //- Assignment of all elements to the given value
452  void operator=(const Type& val);
453 
454  //- Matrix addition
455  void operator+=(const Matrix<Form, Type>& other);
456 
457  //- Matrix subtraction
458  void operator-=(const Matrix<Form, Type>& other);
459 
460  //- Matrix scalar addition
461  void operator+=(const Type& s);
462 
463  //- Matrix scalar subtraction
464  void operator-=(const Type& s);
465 
466  //- Matrix scalar multiplication
467  void operator*=(const Type& s);
468 
469  //- Matrix scalar division
470  void operator/=(const Type& s);
471 
472 
473  // Random Access Iterator (non-const)
474 
475  //- Return an iterator to begin traversing a Matrix
476  inline iterator begin() noexcept;
477 
478  //- Return an iterator to end traversing a Matrix
479  inline iterator end() noexcept;
480 
481 
482  // Random Access Iterator (const)
483 
484  //- Return const_iterator to begin traversing a constant Matrix
485  inline const_iterator cbegin() const noexcept;
486 
487  //- Return const_iterator to end traversing a constant Matrix
488  inline const_iterator cend() const noexcept;
489 
490  //- Return const_iterator to begin traversing a constant Matrix
491  inline const_iterator begin() const noexcept;
492 
493  //- Return const_iterator to end traversing a constant Matrix
494  inline const_iterator end() const noexcept;
495 
496 
497  // IO
498 
499  //- Read Matrix from Istream, discarding existing contents.
500  bool readMatrix(Istream& is);
501 
502  //- Write Matrix, with line-breaks in ASCII when length exceeds
503  //- shortLen.
504  // Using '0' suppresses line-breaks entirely.
505  Ostream& writeMatrix(Ostream& os, const label shortLen=0) const;
506 
507 
508  // Housekeeping
509 
510  //- The number of rows - same as m()
511  inline label mRows() const noexcept
512  {
513  return mRows_;
514  }
515 
516  //- The number of rows - same as m()
517  inline label nRows() const noexcept
518  {
519  return mRows_;
520  }
521 
522  //- The number of columns - same as n()
523  inline label nCols() const noexcept
524  {
525  return nCols_;
526  }
527 
528 
529  //- Deprecated(2019-04) raw data pointer, const access
530  // \deprecated(2019-04) - use cdata() method
531  FOAM_DEPRECATED_FOR(2019-04, "cdata() method")
532  const Type* v() const
533  {
534  return v_;
535  }
536 
537  //- Deprecated(2019-04) raw data pointer, non-const access
538  // \deprecated(2019-04) - use data() method
539  FOAM_DEPRECATED_FOR(2019-04, "data() method")
540  Type* v()
541  {
542  return v_;
543  }
544 
545  //- Deprecated(2019-04) - use subMatrix()
546  // \deprecated(2019-04) - use subMatrix()
547  FOAM_DEPRECATED_FOR(2019-04, "subMatrix() method")
549  (
550  const label m,
551  const label n,
552  const label mStart,
553  const label nStart
554  ) const
555  {
556  return this->subMatrix(mStart, nStart, m, n);
557  }
558 
559  //- Deprecated(2019-04) - use subMatrix()
560  // \deprecated(2019-04) - use subMatrix()
561  FOAM_DEPRECATED_FOR(2019-04, "subMatrix() method")
563  (
564  const label m,
565  const label n,
566  const label mStart,
567  const label nStart
568  )
569  {
570  return this->subMatrix(mStart, nStart, m, n);
571  }
572 
573 
574  //- Deprecated(2019-04) - use subColumn()
575  // \deprecated(2019-04) - use subColumn()
576  FOAM_DEPRECATED_FOR(2019-04, "subColumn() method")
578  (
579  const label m,
580  const label mStart,
581  const label nStart
582  ) const
583  {
584  return this->subColumn(nStart, mStart, m);
585  }
586 
587  //- Deprecated(2019-04) - use subColumn()
588  // \deprecated(2019-04) - use subColumn()
589  FOAM_DEPRECATED_FOR(2019-04, "subColumn() method")
591  (
592  const label m,
593  const label mStart,
594  const label nStart
595  )
596  {
597  return this->subColumn(nStart, mStart, m);
598  }
599 
600  //- Deleted(2019-04) - use subColumn()
601  // \deprecated(2019-04) - use subColumn()
602  void col(const label m, const label rowStart) const = delete;
603 
604  //- Deleted(2019-04) - use subColumn()
605  // \deprecated(2019-04) - use subColumn()
606  void col(const label m, const label rowStart) = delete;
607 };
608 
609 
610 // * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
611 
612 //- Read Matrix from Istream, discarding contents of existing Matrix.
613 template<class Form, class Type>
615 {
616  mat.readMatrix(is);
617  return is;
618 }
619 
620 
621 //- Write Matrix to Ostream, as per Matrix::writeMatrix() with
622 //- default length, which is given by Detail::ListPolicy::short_length
623 template<class Form, class Type>
625 {
627 }
628 
629 
630 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
631 
632 } // End namespace Foam
633 
634 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
635 
636 #include "MatrixI.H"
637 
638 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
639 
640 #ifdef NoRepository
641  #include "Matrix.C"
642  #include "MatrixIO.C"
643 #endif
644 
645 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
646 
647 #endif
648 
649 // ************************************************************************* //
Foam::block
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:58
s
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))
Definition: gmvOutputSpray.H:25
Foam::Matrix::const_iterator
const typedef Type * const_iterator
Random access iterator for traversing a Matrix.
Definition: Matrix.H:126
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Matrix::n
label n() const noexcept
The number of columns.
Definition: MatrixI.H:103
Foam::Matrix::clone
autoPtr< mType > clone() const
Clone.
Definition: MatrixI.H:80
Foam::Matrix::Tmul
tmp< Field< Type > > Tmul(const UList< Type > &x) const
Left-multiply Matrix by a row vector (x * A)
Definition: MatrixI.H:512
Foam::Matrix::writeMatrix
Ostream & writeMatrix(Ostream &os, const label shortLen=0) const
Definition: MatrixIO.C:144
Foam::Matrix::end
iterator end() noexcept
Return an iterator to end traversing a Matrix.
Definition: MatrixI.H:543
Foam::Matrix::mRows
label mRows() const noexcept
The number of rows - same as m()
Definition: Matrix.H:510
Foam::Matrix::data_bytes
char * data_bytes() noexcept
Definition: MatrixI.H:223
Foam::Matrix::checkj
void checkj(const label jcol) const
Check index j is within valid range [0, n)
Definition: MatrixI.H:149
Foam::Matrix::sizes
labelPair sizes() const
Return row/column sizes.
Definition: MatrixI.H:117
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Pair.H
complex.H
Foam::Matrix::mType
Matrix< Form, Type > mType
Matrix type.
Definition: Matrix.H:108
Foam::Matrix::release
List< Type > release()
Definition: Matrix.C:270
Foam::Matrix::cmptType
Type cmptType
Component type.
Definition: Matrix.H:111
Foam::Matrix
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
Definition: DiagonalMatrix.H:53
Foam::Matrix::nCols
label nCols() const noexcept
The number of columns - same as n()
Definition: Matrix.H:522
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Foam::Matrix::transfer
void transfer(Matrix< Form, Type > &mat)
Definition: Matrix.C:304
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::uniform
Definition: uniform.H:50
Foam::Matrix::round
void round(const scalar tol=SMALL)
Round elements with magnitude smaller than tol (SMALL) to zero.
Definition: Matrix.C:379
Foam::Matrix::resize
void resize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
Definition: Matrix.C:324
Foam::Matrix::byteSize
std::streamsize byteSize() const
Definition: Matrix.C:494
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::Matrix::at
const Type & at(const label idx) const
Linear addressing const element access.
Definition: MatrixI.H:257
Foam::MatrixBlock
A templated block of an (m x n) matrix of type <MatrixType>.
Definition: Matrix.H:66
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::Matrix::subRow
ConstMatrixBlock< mType > subRow(const label rowIndex, const label colIndex=0, label len=-1) const
Return const row or const row's subset of Matrix.
Definition: MatrixI.H:314
Foam::Matrix::columnNorm
scalar columnNorm(const label colIndex, const bool noSqrt=false) const
Return L2-Norm of chosen column.
Definition: Matrix.C:463
Foam::Matrix::empty
bool empty() const noexcept
Return true if Matrix is empty (i.e., size() is zero)
Definition: MatrixI.H:124
Foam::Matrix::subMatrix
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:339
Foam::Matrix::cend
const_iterator cend() const noexcept
Return const_iterator to end traversing a constant Matrix.
Definition: MatrixI.H:559
Foam::Detail::ListPolicy::short_length
Number of items before requiring line-breaks in the list output.
Definition: ListPolicy.H:61
Field.H
Foam::Matrix::size_bytes
std::streamsize size_bytes() const noexcept
Definition: MatrixI.H:230
Foam::Matrix::readMatrix
bool readMatrix(Istream &is)
Read Matrix from Istream, discarding existing contents.
Definition: MatrixIO.C:53
Foam::Matrix::clear
void clear()
Clear Matrix, i.e. set sizes to zero.
Definition: Matrix.C:256
Foam::Matrix::rowData
const Type * rowData(const label irow) const
Return const pointer to data in the specified row.
Definition: MatrixI.H:237
Foam::Matrix::iterator
Type * iterator
Random access iterator for traversing a Matrix.
Definition: Matrix.H:123
Foam::Matrix::nRows
label nRows() const noexcept
The number of rows - same as m()
Definition: Matrix.H:516
Foam::Matrix::resize_nocopy
void resize_nocopy(const label mrow, const label ncol)
Change Matrix dimensions without preserving existing content.
Definition: Matrix.C:349
Foam::Matrix::col
ConstMatrixBlock< mType > col(const label m, const label mStart, const label nStart) const
Deprecated(2019-04) - use subColumn()
Definition: Matrix.H:577
Foam::Matrix::shallowResize
void shallowResize(const label m, const label n)
Resize Matrix without reallocating storage (unsafe)
Definition: MatrixI.H:482
Foam::Matrix::size
label size() const
The number of elements in Matrix (m*n)
Definition: MatrixI.H:110
os
OBJstream os(runTime.globalPath()/outputName)
MatrixI.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Matrix::swap
void swap(Matrix< Form, Type > &mat)
Swap contents.
Definition: Matrix.C:290
Foam::Matrix::T
Form T() const
Return (conjugate) transpose of Matrix.
Definition: Matrix.C:392
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::Matrix::trace
Type trace() const
Return the trace.
Definition: Matrix.C:446
Foam::Matrix::Amul
tmp< Field< Type > > Amul(const UList< Type > &x) const
Right-multiply Matrix by a column vector (A * x)
Definition: MatrixI.H:491
Foam::Matrix::m
label m() const noexcept
The number of rows.
Definition: MatrixI.H:96
Foam::Pair< label >
Foam::Matrix::checki
void checki(const label irow) const
Check index i is within valid range [0, m)
Definition: MatrixI.H:131
Foam::Matrix::checkSize
void checkSize() const
Check that dimensions are positive, non-zero.
Definition: MatrixI.H:167
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::Matrix::setSize
void setSize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
Definition: MatrixI.H:475
Foam::Matrix::norm
scalar norm(const bool noSqrt=false) const
Return Frobenius norm of Matrix.
Definition: Matrix.C:480
Foam::Matrix::begin
iterator begin() noexcept
Return an iterator to begin traversing a Matrix.
Definition: MatrixI.H:535
Matrix.C
Foam::Matrix::cdata
const Type * cdata() const noexcept
Definition: MatrixI.H:202
Foam::UList
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:103
Foam::Matrix::cdata_bytes
const char * cdata_bytes() const noexcept
Definition: MatrixI.H:216
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::FOAM_DEPRECATED_FOR
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:69
Foam::ConstMatrixBlock
Definition: Matrix.H:65
Foam::Matrix::subColumn
ConstMatrixBlock< mType > subColumn(const label colIndex, const label rowIndex=0, label len=-1) const
Return const column or column's subset of Matrix.
Definition: MatrixI.H:289
Foam::Matrix::Matrix
Matrix() noexcept
Default construct (empty matrix)
Definition: MatrixI.H:49
Foam::IndirectListBase
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
Definition: IndirectListBase.H:56
Foam::Matrix::cbegin
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing a constant Matrix.
Definition: MatrixI.H:551
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
uLabel.H
Foam::Matrix::v
const Type * v() const
Deprecated(2019-04) raw data pointer, const access.
Definition: Matrix.H:531
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55
MatrixIO.C
Foam::Matrix::diag
List< Type > diag() const
Extract the diagonal elements. Method may change in the future.
Definition: Matrix.C:409
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62
autoPtr.H