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