When the symmetric property of a matrix is know beforehands using the SymmetricMatrix adaptor instead of a general matrix can be a considerable performance advantage. erase ( 0, 2 ) // Erasing the elements (0,2) and (2,0) // Construction from a symmetric dense matrix StaticMatrix B ) // Manipulating the elements (2,4) and (4,2) A ( 2, 4 )( 1, 1 ) = - 5 įor more information on block matrices, see the tutorial on Block Vectors and Matrices. erase ( 0, 0 ) // Erasing the diagonal element (0,0) A. begin ( 1UL ) = 10.0 // Modifies both elements (1,0) and (0,1) // Erasing elements via the erase() function A. insert ( 1, 2, 4.0 ) // Inserting the elements (1,2) and (2,1) // Access via a non-const iterator * A. insert ( 1, 1, 3.0 ) // Inserting the diagonal element (1,1) A. Using blaze :: CompressedMatrix using blaze :: DynamicMatrix using blaze :: StaticMatrix using blaze :: SymmetricMatrix using blaze :: rowMajor // Default constructed, row-major 3x3 symmetric compressed matrix SymmetricMatrix > A ( 3 ) // Initializing three elements via the function call operator A ( 0, 0 ) = 1.0 // Initialization of the diagonal element (0,0) A ( 0, 2 ) = 2.0 // Initialization of the elements (0,2) and (2,0) // Inserting three more elements via the insert() function A. In case a resizable matrix is used (as for instance blaze::HybridMatrix, blaze::DynamicMatrix, or blaze::CompressedMatrix), this means that the according constructors, the resize() and the extend() functions only expect a single parameter, which specifies both the number of rows and columns, instead of two (one for the number of rows and one for the number of columns): However, there are some important exceptions resulting from the symmetry constraint: It also provides (nearly) the same interface as the underlying matrix type. is specified as blaze::columnMajor), the symmetric matrix will also be a column-major matrix.Ī symmetric matrix is used exactly like a matrix of the underlying, adapted matrix type MT. Otherwise, if the adapted matrix is column-major (i.e. is specified as blaze::rowMajor), the symmetric matrix will also be a row-major matrix. In case the adapted matrix is stored in a row-wise fashion (i.e. The storage order of a symmetric matrix is depending on the storage order of the adapted matrix type MT. Using blaze :: unaligned using blaze :: unpadded using blaze :: rowMajor using blaze :: columnMajor // Definition of a 3x3 row-major dense symmetric matrix with static memory blaze :: SymmetricMatrix > A // Definition of a resizable column-major dense symmetric matrix based on HybridMatrix blaze :: SymmetricMatrix B // Definition of a resizable row-major dense symmetric matrix based on DynamicMatrix blaze :: SymmetricMatrix > C // Definition of a fixed size row-major dense symmetric matrix based on CustomMatrix blaze :: SymmetricMatrix > D // Definition of a compressed row-major single precision symmetric matrix blaze :: SymmetricMatrix > E the matrix is always equal to its transpose A = A T). It inherits the properties and the interface of the given matrix type MT and extends it by enforcing the additional invariant of symmetry (i.e. The blaze::SymmetricMatrix class template is an adapter for existing dense and sparse matrix types. Within the Blaze library, symmetric matrices are realized by the SymmetricMatrix class template. This symmetry property can be exploited to provide higher efficiency and/or lower memory consumption. Mathematically, this means that a symmetric matrix is always equal to its transpose (A = A T) and that all non-diagonal values have an identical counterpart (a ij = a ji). In contrast to plain matrices, which have no restriction in their number of rows and columns and whose elements can have any value, symmetric matrices provide the compile time guarantee to be square matrices with pair-wise identical values. Negative Impact: Assignment of a General Matrix.Positive Impact: Row/Column Views on Column/Row-Major Matrices. Positive Impact: Matrix/Vector Multiplication.Positive Impact: Matrix/Matrix Multiplication.The Elements of a Dense Symmetric Matrix are Always Default Initialized.The Symmetry Property is Always Enforced.Symmetric Matrices Must Always be Square.Special Properties of Symmetric Matrices.
0 Comments
Leave a Reply. |