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