BELFEM 0.9.4
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 final
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 ~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 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 template < typename MT, bool SO >
595 operator+=( const blaze::Matrix< MT, SO > & aExpression )
596 {
597 mMatrix += aExpression;
598 return *this;
599 }
600
601//------------------------------------------------------------------------------
602// SUBTRACT OPERATORS
603//------------------------------------------------------------------------------
604
606 operator-=( const T & aValue )
607 {
608 mMatrix -= aValue;
609 return *this;
610 }
611
612// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
613
615 operator-=( const Matrix< T > & aMatrix )
616 {
617 mMatrix -= aMatrix.matrix_data();
618 return *this;
619 }
620
621// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
622
623 template < typename MT, bool SO >
625 operator-=( const blaze::Matrix< MT, SO > & aExpression )
626 {
627 mMatrix -= aExpression;
628 return *this;
629 }
630
631// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
632
634 operator-=( const MatrixType & aExpression )
635 {
636 mMatrix -= aExpression;
637 return *this;
638 }
639
640//------------------------------------------------------------------------------
641// MULTIPLY OPERATORS
642//------------------------------------------------------------------------------
643
645 operator*=( const T & aValue )
646 {
647 mMatrix *= aValue;
648 return *this;
649 }
650
651// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
652
654 operator*=( const Matrix< T > & aMatrix )
655 {
656 mMatrix *= aMatrix.matrix_data();
657 return *this;
658 }
659
660// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
661
666 template < typename MT, bool SO >
668 operator*=( const blaze::Matrix< MT, SO > & aExpression )
669 {
670 MatrixType tProduct( mMatrix * ( *aExpression ) );
671 mMatrix = std::move( tProduct );
672 return *this;
673 }
674
675// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
676
678 operator*=( const MatrixType & aExpression )
679 {
680 mMatrix *= aExpression;
681 return *this;
682 }
683
684//------------------------------------------------------------------------------
685// DIVIDE OPERATORS
686//------------------------------------------------------------------------------
687
689 operator/=( const T & aValue )
690 {
691 mMatrix /= aValue;
692 return *this;
693 }
694
695//------------------------------------------------------------------------------
696// PRINT OPERATION
697//------------------------------------------------------------------------------
698
699 inline void
700 print( const std::string aLabel="Matrix" ) const;
701
702//------------------------------------------------------------------------------
703 };
704//------------------------------------------------------------------------------
705// turn off annoying waning
706#ifdef BELFEM_GCC
707#pragma GCC diagnostic push
708#pragma GCC diagnostic ignored "-Wformat"
709#endif
710 template < typename T > void
711 Matrix< T >::print( const std::string aLabel ) const
712 {
713 FILE * tOutFile = stdout;
714
715 fprintf( tOutFile, "%s = [ ... \n", aLabel.c_str() );
716
717 // get a ref of this
718 const Matrix< T > & tThis = *this;
719
720 uint tRows = tThis.n_rows();
721 uint tCols = tThis.n_cols();
722
723 for( uint i=0; i< tRows; ++i )
724 {
725 for( uint j=0; j< tCols; ++j )
726 {
727 if( j < tCols-1 )
728 {
729 fprintf( tOutFile, "%d, ", ( int ) tThis( i, j ) );
730 }
731 else
732 {
733 fprintf( tOutFile, "%d; ", ( int ) tThis( i, j ) );
734 }
735 }
736
737 if( i < tRows-1 )
738 {
739 fprintf( tOutFile, "...\n" );
740 }
741 else
742 {
743 fprintf( tOutFile, "];\n" );
744 }
745 }
746 }
747
748// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
749
750 template <>
751 inline void
752 Matrix<real>::print( const std::string aLabel ) const
753 {
754 FILE * tOutFile = stdout;
755
756 fprintf( tOutFile, "%s = [ ... \n", aLabel.c_str() );
757
758 const Matrix< real > & tThis = *this;
759
760 uint tRows = tThis.n_rows();
761 uint tCols = tThis.n_cols();
762
763 for( uint i=0; i< tRows; ++i )
764 {
765 for( uint j=0; j< tCols; ++j )
766 {
767 if( j < tCols-1 )
768 {
769 fprintf( tOutFile, "%+.15e, ", ( double ) tThis( i, j ) );
770 }
771 else
772 {
773 fprintf( tOutFile, "%+.15e; ", ( double ) tThis( i, j ) );
774 }
775 }
776
777 if( i < tRows-1 )
778 {
779 fprintf( tOutFile, "...\n" );
780 }
781 else
782 {
783 fprintf( tOutFile, "];\n" );
784 }
785 }
786 }
787
788#ifdef BELFEM_GCC
789#pragma GCC diagnostic pop
790#endif
791}
792#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
Matrix< T > & operator-=(const blaze::Matrix< MT, SO > &aExpression)
Definition cl_BZ_Matrix.hpp:625
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:329
const MatrixType & matrix_data() const
Definition cl_BZ_Matrix.hpp:179
const T & operator()(const size_t aRowIndex, const size_t aColIndex) const
access operator ( const version )
Definition cl_BZ_Matrix.hpp:310
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:301
Matrix< T > & operator/=(const T &aValue)
Definition cl_BZ_Matrix.hpp:689
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:606
Matrix(const MatrixType &aExpression)
Definition cl_BZ_Matrix.hpp:72
Matrix< T > & operator-=(const MatrixType &aExpression)
Definition cl_BZ_Matrix.hpp:634
Matrix< T > & operator*=(const blaze::Matrix< MT, SO > &aExpression)
in-place product with a matrix expression: as Blaze's own operator, the product is formed in a tempor...
Definition cl_BZ_Matrix.hpp:668
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:615
Matrix()=default
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
Matrix< T > & operator*=(const MatrixType &aExpression)
Definition cl_BZ_Matrix.hpp:678
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:654
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()=default
empty destructor
Matrix< T > & operator*=(const T &aValue)
Definition cl_BZ_Matrix.hpp:645
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
Matrix< T > & operator+=(const blaze::Matrix< MT, SO > &aExpression)
Definition cl_BZ_Matrix.hpp:595
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:261
size_t length() const
get the length of the vector
Definition cl_AR_Vector.hpp:333
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30