BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_BZ_Matrix.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_CL_BZ_MATRIX_HPP
13#define BELFEM_CL_BZ_MATRIX_HPP
14
15#include "typedefs.hpp"
16#include "assert.hpp"
17namespace belfem
18{
26 template< typename T >
27 class Matrix
28 {
29//------------------------------------------------------------------------------
30 public :
31//------------------------------------------------------------------------------
32
33 typedef blaze::DynamicMatrix< T, BLAZE_DEFAULT_STORAGE_ORDER > MatrixType;
34
35//------------------------------------------------------------------------------
36 private :
37//------------------------------------------------------------------------------
38
39 // member class of underlying vector implementation
40 MatrixType mMatrix;
41
42//------------------------------------------------------------------------------
43 public :
44//------------------------------------------------------------------------------
45
46 Matrix() = default;
47
48// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
49
50 Matrix( const size_t aNumRows,
51 const size_t aNumCols ) :
52 mMatrix( aNumRows, aNumCols ) {}
53
54// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
55
56 Matrix( const size_t aNumRows,
57 const size_t aNumCols,
58 const T aValue ) :
59 mMatrix( aNumRows, aNumCols, aValue )
60 {}
61
62// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63
64 Matrix( const std::initializer_list<std::initializer_list<T> > & aInitList )
65 : mMatrix( aInitList )
66 {
67
68 }
69
70// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
71
72 Matrix( const MatrixType & aExpression )
73 : mMatrix( aExpression ) {}
74
75// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76
80 template< typename MT, bool SO >
81 Matrix( const blaze::Matrix< MT, SO > & aExpression )
82 : mMatrix( aExpression ) {}
83
84// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
85
89 template< typename VT >
90 Matrix( const blaze::DenseVector< VT, false > & aExpression )
91 {
92 const VT & tVector = static_cast< const VT& >( aExpression );
93 mMatrix.resize( tVector.size(), 1UL, false );
94
95 for ( size_t k = 0; k < tVector.size(); ++k )
96 {
97 mMatrix( k, 0 ) = tVector[ k ];
98 }
99 }
100
101// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102
106 template< typename VT >
107 Matrix( const blaze::DenseVector< VT, true > & aExpression )
108 {
109 const VT & tVector = static_cast< const VT& >( aExpression );
110 mMatrix.resize( 1UL, tVector.size(), false );
111
112 for ( size_t k = 0; k < tVector.size(); ++k )
113 {
114 mMatrix( 0, k ) = tVector[ k ];
115 }
116 }
117
118//------------------------------------------------------------------------------
119
123 Matrix( const Matrix< T > & aMatrix ) :
124 mMatrix( aMatrix.mMatrix )
125 {}
126
130 Matrix( Matrix< T > && aMatrix ) noexcept :
131 mMatrix( std::move( aMatrix.mMatrix ) )
132 {}
133
134//------------------------------------------------------------------------------
135
139 virtual ~Matrix() = default;
140
141//------------------------------------------------------------------------------
142// MEMORY
143//------------------------------------------------------------------------------
144
145
148 inline T *
150 {
151 return mMatrix.data();
152 }
153
154// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
155
156 inline const T *
157 data() const
158 {
159 return mMatrix.data();
160 }
161
162//------------------------------------------------------------------------------
163
164 /*
165 * expose the underlying matrix implementation ( writable version )
166 */
167 inline MatrixType &
169 {
170 return mMatrix;
171 }
172
173// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
174
175 /*
176 * expose the underlying matrix implementation ( const version )
177 */
178 inline const MatrixType &
180 {
181 return mMatrix;
182 }
183
184//------------------------------------------------------------------------------
185// UTILITIES
186//------------------------------------------------------------------------------
187
188 inline void
189 fill( const T & aValue )
190 {
191 mMatrix = aValue;
192 }
193
194//------------------------------------------------------------------------------
195
196 inline void
197 set_size( const size_t aNumRows, const size_t aNumCols )
198 {
199 mMatrix.resize( aNumRows, aNumCols, false );
200 }
201
202// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
203
204 inline void
205 set_size( const size_t aNumRows, const size_t aNumCols, const T & aValue )
206 {
207 this->set_size( aNumRows, aNumCols );
208 this->fill( aValue );
209 }
210
211//------------------------------------------------------------------------------
212// SIZE CHECKS
213//------------------------------------------------------------------------------
214
215 inline size_t
216 n_rows() const
217 {
218 return mMatrix.rows();
219 }
220
221//------------------------------------------------------------------------------
222
223 inline size_t
224 n_cols() const
225 {
226 return mMatrix.columns();
227 }
228
229//------------------------------------------------------------------------------
230
234 inline size_t
235 capacity() const
236 {
237 return mMatrix.capacity();
238 }
239
240//------------------------------------------------------------------------------
241
247 inline size_t
248 spacing() const
249 {
250 return mMatrix.spacing();
251 }
252
253//------------------------------------------------------------------------------
254// OPERATORS
255//------------------------------------------------------------------------------
256
261 operator=( Matrix< T > && aMatrix ) noexcept
262 {
263 if ( this != & aMatrix )
264 {
265 mMatrix = std::move( aMatrix.mMatrix );
266 }
267 return *this;
268 }
269
274 operator=( const Matrix< T > & aMatrix )
275 {
276 if ( this != &aMatrix )
277 {
278 mMatrix = aMatrix.mMatrix;
279 }
280 return *this;
281 }
282
283//------------------------------------------------------------------------------
284
288 inline T &
289 operator()( const size_t aRowIndex, const size_t aColIndex )
290 {
291 BELFEM_ASSERT( aRowIndex< this->n_rows(),
292 "Row index %lu out of bounds, which must be smaller than %lu.",
293 ( long unsigned int ) aRowIndex,
294 ( long unsigned int ) this->n_rows() );
295
296 BELFEM_ASSERT( aColIndex< this->n_cols(),
297 "Col index %lu out of bounds, which must be smaller than %lu.",
298 ( long unsigned int ) aColIndex,
299 ( long unsigned int ) this->n_cols() );
300
301 return mMatrix( aRowIndex, aColIndex );
302 }
303
304// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
305
309 virtual inline const T &
310 operator()( const size_t aRowIndex, const size_t aColIndex ) const
311 {
312 BELFEM_ASSERT( aRowIndex< this->n_rows(),
313 "Row index %lu out of bounds, which must be smaller than %lu.",
314 ( long unsigned int ) aRowIndex,
315 ( long unsigned int ) this->n_rows() );
316
317 BELFEM_ASSERT( aColIndex< this->n_cols(),
318 "Col index %lu out of bounds, which must be smaller than %lu.",
319 ( long unsigned int ) aColIndex,
320 ( long unsigned int ) this->n_cols() );
321
322 return mMatrix( aRowIndex, aColIndex );
323 }
324
325//------------------------------------------------------------------------------
326// Cols and Rows
327//------------------------------------------------------------------------------
328
329 inline auto
330 row( const size_t aRowIndex )
331 ->decltype( blaze::row( mMatrix, aRowIndex ) )
332 {
333 BELFEM_ASSERT( aRowIndex < this->n_rows(),
334 "Row index %lu out of bounds, which must be less than %lu.",
335 ( long unsigned int ) aRowIndex,
336 ( long unsigned int ) this->n_rows() );
337
338 return blaze::row( mMatrix, aRowIndex );
339 }
340
341// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
342
343 inline auto
344 row( const size_t aRowIndex ) const
345 ->decltype( blaze::row( mMatrix, aRowIndex ) )
346 {
347 BELFEM_ASSERT( aRowIndex < this->n_rows(),
348 "Row index %lu out of bounds, which must be less than %lu.",
349 ( long unsigned int ) aRowIndex,
350 ( long unsigned int ) this->n_rows() );
351
352 return blaze::row( mMatrix, aRowIndex );
353 }
354
355//------------------------------------------------------------------------------
356
357 inline auto
358 col( const size_t aColIndex )
359 ->decltype( blaze::column( mMatrix, aColIndex ) )
360 {
361 BELFEM_ASSERT( aColIndex < this->n_cols(),
362 "Col index %lu out of bounds, which must be less than %lu.",
363 ( long unsigned int ) aColIndex,
364 ( long unsigned int ) this->n_cols() );
365
366 return blaze::column( mMatrix, aColIndex );
367 }
368
369// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
370
371 inline auto
372 col( const size_t aColIndex ) const
373 ->decltype( blaze::column( mMatrix, aColIndex ) )
374 {
375 BELFEM_ASSERT( aColIndex < this->n_cols(),
376 "Col index %lu out of bounds, which must be less than %lu.",
377 ( long unsigned int ) aColIndex,
378 ( long unsigned int ) this->n_cols() );
379
380 return blaze::column( mMatrix, aColIndex );
381 }
382
383//------------------------------------------------------------------------------
384
385 inline auto
386 submat( const size_t aFirstRow,
387 const size_t aFirstCol,
388 const size_t aLastRow,
389 const size_t aLastCol )
390 -> decltype( blaze::submatrix( mMatrix, aFirstRow, aFirstCol, aLastRow, aLastCol ) )
391 {
392 BELFEM_ASSERT( aFirstRow < this->n_rows(),
393 "First row index %lu out of bounds, which must be less than %lu.",
394 ( long unsigned int ) aFirstRow,
395 ( long unsigned int ) this->n_rows() );
396
397 BELFEM_ASSERT( aLastRow < this->n_rows(),
398 "Last row index %lu out of bounds, which must be less than %lu.",
399 ( long unsigned int ) aLastRow,
400 ( long unsigned int ) this->n_rows() );
401
402 BELFEM_ASSERT( aFirstCol < this->n_cols(),
403 "First col index %lu out of bounds, which must be less than %lu.",
404 ( long unsigned int ) aFirstCol,
405 ( long unsigned int ) this->n_cols() );
406
407 BELFEM_ASSERT( aLastCol < this->n_cols(),
408 "Last col index %lu out of bounds, which must be less than %lu.",
409 ( long unsigned int ) aLastCol,
410 ( long unsigned int ) this->n_cols() );
411
412 // blaze takes ( row, col, #rows, #cols ); the interface uses the
413 // Armadillo convention of INCLUSIVE last indices
414 return blaze::submatrix( mMatrix, aFirstRow, aFirstCol,
415 aLastRow - aFirstRow + 1, aLastCol - aFirstCol + 1 );
416 }
417
418// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
419
420 inline auto
421 submat( const size_t aFirstRow,
422 const size_t aFirstCol,
423 const size_t aLastRow,
424 const size_t aLastCol ) const
425 -> decltype( blaze::submatrix( mMatrix, aFirstRow, aFirstCol, aLastRow, aLastCol ) )
426 {
427 BELFEM_ASSERT( aFirstRow < this->n_rows(),
428 "First row index %lu out of bounds, which must be less than %lu.",
429 ( long unsigned int ) aFirstRow,
430 ( long unsigned int ) this->n_rows() );
431
432 BELFEM_ASSERT( aLastRow < this->n_rows(),
433 "Last row index %lu out of bounds, which must be less than %lu.",
434 ( long unsigned int ) aLastRow,
435 ( long unsigned int ) this->n_rows() );
436
437 BELFEM_ASSERT( aFirstCol < this->n_cols(),
438 "First col index %lu out of bounds, which must be less than %lu.",
439 ( long unsigned int ) aFirstCol,
440 ( long unsigned int ) this->n_cols() );
441
442 BELFEM_ASSERT( aLastCol < this->n_cols(),
443 "Last col index %lu out of bounds, which must be less than %lu.",
444 ( long unsigned int ) aLastCol,
445 ( long unsigned int ) this->n_cols() );
446
447 // blaze takes ( row, col, #rows, #cols ); the interface uses the
448 // Armadillo convention of INCLUSIVE last indices
449 return blaze::submatrix( mMatrix, aFirstRow, aFirstCol,
450 aLastRow - aFirstRow + 1, aLastCol - aFirstCol + 1 );
451 }
452
453//------------------------------------------------------------------------------
454
455 inline void
456 set_row( const size_t aRowIndex, const Vector <T> & aVector )
457 {
458
459 // make sure that length is correct
460 BELFEM_ASSERT( aVector.length() == this->n_cols(),
461 "Wrong length of vector : %lu ( expect %lu )",
462 ( long unsigned int ) aVector.length(),
463 ( long unsigned int ) this->n_cols() );
464
465 // get pointer to data
466 const T * tSource = aVector.data();
467
468 // manual copy of data
469 for( std::size_t k=0; k<aVector.length(); ++k )
470 {
471 mMatrix( aRowIndex, k ) = tSource[ k ];
472 }
473 }
474
475//------------------------------------------------------------------------------
476
477 template < typename ET >
478 inline void
479 set_row( const size_t aRowIndex, const ET & aExpression )
480 {
481 this->row( aRowIndex ) = aExpression;
482 }
483
484//------------------------------------------------------------------------------
485
486 inline void
487 set_col( const size_t aColIndex, const Vector <T> & aVector )
488 {
489 // make sure that length is correct
490 BELFEM_ASSERT( aVector.length() == this->n_rows(),
491 "Wrong length of vector : %lu ( expect %lu )",
492 ( long unsigned int ) aVector.length(),
493 ( long unsigned int ) this->n_rows() );
494
495 std::copy( aVector.data(), aVector.data() + aVector.length(),
496 this->col( aColIndex ).data() );
497 }
498
499 template < typename ET >
500 inline void
501 set_col( const size_t aRowIndex, const ET & aExpression )
502 {
503 this->col( aRowIndex ) = aExpression;
504 }
505
506//------------------------------------------------------------------------------
507// internal operators
508//------------------------------------------------------------------------------
509
514 operator=( const T & aValue )
515 {
516 this->fill( aValue );
517 return *this;
518 }
519
520// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
521
525 template < typename MT, bool SO >
527 operator=( const blaze::Matrix< MT, SO > & aExpression )
528 {
529 mMatrix = aExpression;
530 return *this;
531 }
532
533// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
534
538 template < typename VT >
540 operator=( const blaze::DenseVector< VT, false > & aExpression )
541 {
542 const VT & tVector = static_cast< const VT& >( aExpression );
543 mMatrix.resize( tVector.size(), 1UL, false );
544
545 for ( size_t k = 0; k < tVector.size(); ++k )
546 {
547 mMatrix( k, 0 ) = tVector[ k ];
548 }
549 return *this;
550 }
551
552// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
553
557 template < typename VT >
559 operator=( const blaze::DenseVector< VT, true > & aExpression )
560 {
561 const VT & tVector = static_cast< const VT& >( aExpression );
562 mMatrix.resize( 1UL, tVector.size(), false );
563
564 for ( size_t k = 0; k < tVector.size(); ++k )
565 {
566 mMatrix( 0, k ) = tVector[ k ];
567 }
568 return *this;
569 }
570
571//------------------------------------------------------------------------------
572// ADD OPERATORS
573//------------------------------------------------------------------------------
574
576 operator+=( const T & aValue )
577 {
578 mMatrix += aValue;
579 return *this;
580 }
581
582// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
583
585 operator+=( const Matrix< T > & aMatrix )
586 {
587 mMatrix += aMatrix.matrix_data();
588 return *this;
589 }
590
591// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
592
593#ifdef BELFEM_GCC
594 template < typename MT, bool SO >
596 operator+=( const blaze::Matrix< MT, SO > & aExpression )
597 {
598 mMatrix += aExpression;
599 return *this;
600 }
601#endif
602
603//------------------------------------------------------------------------------
604// SUBTRACT OPERATORS
605//------------------------------------------------------------------------------
606
608 operator-=( const T & aValue )
609 {
610 mMatrix -= aValue;
611 return *this;
612 }
613
614// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
615
617 operator-=( const Matrix< T > & aMatrix )
618 {
619 mMatrix -= aMatrix.matrix_data();
620 return *this;
621 }
622
623// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
624
625#ifdef BELFEM_GCC
626 template < typename MT, bool SO >
628 operator-=( const blaze::Matrix< MT, SO > & aExpression )
629 {
630 mMatrix -= aExpression;
631 return *this;
632 }
633
634// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
635
637 operator-=( const MatrixType & aExpression )
638 {
639 mMatrix -= aExpression;
640 return *this;
641 }
642#endif
643
644//------------------------------------------------------------------------------
645// MULTIPLY OPERATORS
646//------------------------------------------------------------------------------
647
649 operator*=( const T & aValue )
650 {
651 mMatrix *= aValue;
652 return *this;
653 }
654
655// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
656
658 operator*=( const Matrix< T > & aMatrix )
659 {
660 mMatrix *= aMatrix.matrix_data();
661 return *this;
662 }
663
664// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
665
666#ifdef BELFEM_GCC
667 template < typename MT, bool SO >
669 operator*=( const blaze::Matrix< MT, SO > & aExpression )
670 {
671 mMatrix *= aExpression;
672 return *this;
673 }
674
675// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
676
678 operator*=( const MatrixType & aExpression )
679 {
680 mMatrix *= aExpression;
681 return *this;
682 }
683#endif
684
685//------------------------------------------------------------------------------
686// DIVIDE OPERATORS
687//------------------------------------------------------------------------------
688
690 operator/=( const T & aValue )
691 {
692 mMatrix /= aValue;
693 return *this;
694 }
695
696//------------------------------------------------------------------------------
697// PRINT OPERATION
698//------------------------------------------------------------------------------
699
700 inline void
701 print( const std::string aLabel="Matrix" ) const;
702
703//------------------------------------------------------------------------------
704 };
705//------------------------------------------------------------------------------
706// turn off annoying waning
707#ifdef BELFEM_GCC
708#pragma GCC diagnostic push
709#pragma GCC diagnostic ignored "-Wformat"
710#endif
711 template < typename T > void
712 Matrix< T >::print( const std::string aLabel ) const
713 {
714 FILE * tOutFile = stdout;
715
716 fprintf( tOutFile, "%s = [ ... \n", aLabel.c_str() );
717
718 // get a ref of this
719 const Matrix< T > & tThis = *this;
720
721 uint tRows = tThis.n_rows();
722 uint tCols = tThis.n_cols();
723
724 for( uint i=0; i< tRows; ++i )
725 {
726 for( uint j=0; j< tCols; ++j )
727 {
728 if( j < tCols-1 )
729 {
730 fprintf( tOutFile, "%d, ", ( int ) tThis( i, j ) );
731 }
732 else
733 {
734 fprintf( tOutFile, "%d; ", ( int ) tThis( i, j ) );
735 }
736 }
737
738 if( i < tRows-1 )
739 {
740 fprintf( tOutFile, "...\n" );
741 }
742 else
743 {
744 fprintf( tOutFile, "];\n" );
745 }
746 }
747 }
748
749// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
750
751 template <>
752 inline void
753 Matrix<real>::print( const std::string aLabel ) const
754 {
755 FILE * tOutFile = stdout;
756
757 fprintf( tOutFile, "%s = [ ... \n", aLabel.c_str() );
758
759 const Matrix< real > & tThis = *this;
760
761 uint tRows = tThis.n_rows();
762 uint tCols = tThis.n_cols();
763
764 for( uint i=0; i< tRows; ++i )
765 {
766 for( uint j=0; j< tCols; ++j )
767 {
768 if( j < tCols-1 )
769 {
770 fprintf( tOutFile, "%+.15e, ", ( double ) tThis( i, j ) );
771 }
772 else
773 {
774 fprintf( tOutFile, "%+.15e; ", ( double ) tThis( i, j ) );
775 }
776 }
777
778 if( i < tRows-1 )
779 {
780 fprintf( tOutFile, "...\n" );
781 }
782 else
783 {
784 fprintf( tOutFile, "];\n" );
785 }
786 }
787 }
788
789#ifdef BELFEM_GCC
790#pragma GCC diagnostic pop
791#endif
792}
793#endif //BELFEM_CL_BZ_MATRIX_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Dense column-major matrix.
Definition cl_BZ_Matrix.hpp:28
Matrix< T > & operator=(Matrix< T > &&aMatrix) noexcept
move assignment operator
Definition cl_BZ_Matrix.hpp:261
size_t spacing() const
inter-column stride of the data container ( the leading dimension in BLAS terms; exceeds n_rows when ...
Definition cl_BZ_Matrix.hpp:248
Matrix< T > & operator+=(const T &aValue)
Definition cl_BZ_Matrix.hpp:576
auto submat(const size_t aFirstRow, const size_t aFirstCol, const size_t aLastRow, const size_t aLastCol) -> decltype(blaze::submatrix(mMatrix, aFirstRow, aFirstCol, aLastRow, aLastCol))
Definition cl_BZ_Matrix.hpp:386
void set_size(const size_t aNumRows, const size_t aNumCols, const T &aValue)
Definition cl_BZ_Matrix.hpp:205
virtual ~Matrix()=default
empty destructor
Matrix< T > & operator=(const blaze::DenseVector< VT, false > &aExpression)
Fill with column vector expression.
Definition cl_BZ_Matrix.hpp:540
auto col(const size_t aColIndex) -> decltype(mMatrix.col(aColIndex))
Definition cl_AR_Matrix.hpp:325
const MatrixType & matrix_data() const
Definition cl_BZ_Matrix.hpp:179
void fill(const T &aValue)
Definition cl_BZ_Matrix.hpp:189
auto row(const size_t aRowIndex) -> decltype(mMatrix.row(aRowIndex))
Definition cl_AR_Matrix.hpp:297
Matrix< T > & operator/=(const T &aValue)
Definition cl_BZ_Matrix.hpp:690
Matrix(const size_t aNumRows, const size_t aNumCols)
Definition cl_BZ_Matrix.hpp:50
Matrix< T > & operator=(const blaze::Matrix< MT, SO > &aExpression)
Fill with matrix expression.
Definition cl_BZ_Matrix.hpp:527
void set_row(const size_t aRowIndex, const Vector< T > &aVector)
Definition cl_BZ_Matrix.hpp:456
MatrixType & matrix_data()
Definition cl_BZ_Matrix.hpp:168
size_t capacity() const
The allocated element count, which may exceed spacing() * n_cols() after a resize shrinks the matrix.
Definition cl_BZ_Matrix.hpp:235
Matrix< T > & operator-=(const T &aValue)
Definition cl_BZ_Matrix.hpp:608
Matrix(const MatrixType &aExpression)
Definition cl_BZ_Matrix.hpp:72
auto row(const size_t aRowIndex) const -> decltype(blaze::row(mMatrix, aRowIndex))
Definition cl_BZ_Matrix.hpp:344
void set_row(const size_t aRowIndex, const ET &aExpression)
Definition cl_BZ_Matrix.hpp:479
void set_size(const size_t aNumRows, const size_t aNumCols)
Definition cl_BZ_Matrix.hpp:197
size_t n_rows() const
Definition cl_BZ_Matrix.hpp:216
Matrix(const blaze::DenseVector< VT, true > &aExpression)
Constructor from row vector expression.
Definition cl_BZ_Matrix.hpp:107
void set_col(const size_t aColIndex, const Vector< T > &aVector)
Definition cl_BZ_Matrix.hpp:487
Matrix(const Matrix< T > &aMatrix)
copy constructor
Definition cl_BZ_Matrix.hpp:123
Matrix< T > & operator=(const Matrix< T > &aMatrix)
copy assignment operator
Definition cl_BZ_Matrix.hpp:274
T & operator()(const size_t aRowIndex, const size_t aColIndex)
access operator ( writable version )
Definition cl_BZ_Matrix.hpp:289
arma::Mat< T > MatrixType
Definition cl_AR_Matrix.hpp:34
auto col(const size_t aColIndex) const -> decltype(blaze::column(mMatrix, aColIndex))
Definition cl_BZ_Matrix.hpp:372
Matrix(const blaze::Matrix< MT, SO > &aExpression)
Constructor from matrix expression.
Definition cl_BZ_Matrix.hpp:81
Matrix< T > & operator=(const T &aValue)
Fill with value.
Definition cl_BZ_Matrix.hpp:514
Matrix< T > & operator-=(const Matrix< T > &aMatrix)
Definition cl_BZ_Matrix.hpp:617
Matrix()=default
virtual const T & operator()(const size_t aRowIndex, const size_t aColIndex) const
access operator ( const version )
Definition cl_BZ_Matrix.hpp:310
size_t n_cols() const
Definition cl_BZ_Matrix.hpp:224
Matrix(Matrix< T > &&aMatrix) noexcept
move constructor
Definition cl_BZ_Matrix.hpp:130
Matrix(const std::initializer_list< std::initializer_list< T > > &aInitList)
Definition cl_BZ_Matrix.hpp:64
void set_col(const size_t aRowIndex, const ET &aExpression)
Definition cl_BZ_Matrix.hpp:501
Matrix(const blaze::DenseVector< VT, false > &aExpression)
Constructor from column vector expression.
Definition cl_BZ_Matrix.hpp:90
auto col(const size_t aColIndex) -> decltype(blaze::column(mMatrix, aColIndex))
Definition cl_BZ_Matrix.hpp:358
Matrix< T > & operator*=(const Matrix< T > &aMatrix)
Definition cl_BZ_Matrix.hpp:658
Matrix< T > & operator=(const blaze::DenseVector< VT, true > &aExpression)
Fill with row vector expression.
Definition cl_BZ_Matrix.hpp:559
auto submat(const size_t aFirstRow, const size_t aFirstCol, const size_t aLastRow, const size_t aLastCol) const -> decltype(blaze::submatrix(mMatrix, aFirstRow, aFirstCol, aLastRow, aLastCol))
Definition cl_BZ_Matrix.hpp:421
Matrix< T > & operator*=(const T &aValue)
Definition cl_BZ_Matrix.hpp:649
const T * data() const
Definition cl_BZ_Matrix.hpp:157
void print(const std::string aLabel="Matrix") const
auto row(const size_t aRowIndex) -> decltype(blaze::row(mMatrix, aRowIndex))
Definition cl_BZ_Matrix.hpp:330
Matrix(const size_t aNumRows, const size_t aNumCols, const T aValue)
Definition cl_BZ_Matrix.hpp:56
T * data()
Returns a borrowed raw buffer under the layout contract stated in cl_Matrix.hpp; may be nullptr when ...
Definition cl_BZ_Matrix.hpp:149
Matrix< T > & operator+=(const Matrix< T > &aMatrix)
Definition cl_BZ_Matrix.hpp:585
T * data()
Returns a borrowed raw buffer under the layout contract stated in cl_Vector.hpp; may be nullptr when ...
Definition cl_AR_Vector.hpp:163
size_t length() const
get the length of the vector
Definition cl_AR_Vector.hpp:235
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30