Difference between revisions of "Procedural"

From Efficient Java Matrix Library
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
The procedural interface in EJML provides access to all of its capabilities and provides much more control over which algorithms are used and when memory is created.  The downside to this increased control is the added difficulty in programming, kinda resembles writing in assembly.  Code can be made very efficient, but managing all the temporary data structures can be tedious.   
 
The procedural interface in EJML provides access to all of its capabilities and provides much more control over which algorithms are used and when memory is created.  The downside to this increased control is the added difficulty in programming, kinda resembles writing in assembly.  Code can be made very efficient, but managing all the temporary data structures can be tedious.   
  
The procedural API processes [[DenseMatrix]] matrix types.  There are functions for real matrices [http://ejml.org/javadoc/org/ejml/data/DenseMatrix64F.html DenseMatrix64F], complex [http://ejml.org/javadoc/org/ejml/data/CDenseMatrix64F.html CDenseMatrix64F], and fixed sized (FixedMatrix2x2_64F, ..., FixedMatrix6x6_64F)These classes themselves only provide very basic operators for accessing elements within a matrix and well as its size and shapeThe complete set of functions for manipulating DenseMatrix are available in various Ops classes, described below.
+
The procedural supports all matrix types in EJML and follows a consistent naming pattern across all matrix types. Ops classes end in a suffix that indicate which type of matrix they can processFrom the matrix name you can determine the type of element (float,double,real,complex) and it's internal data structure, e.g. row-major or block. In general, almost everyone will want to interact with row major matricesConversion to block format is done automatically internally when it becomes advantageous.   
  
Internally all dense matrix classes store the matrix in a single array using a row-major format. Fixed sized matrices and vectors unroll the matrix, where each element is a matrix parameterThis can allow for much faster access and array overheadHowever if fixed sized matrices get too large then performance starts to drop due to what I suppose is CPU caching issues.
+
{| class="wikitable"
 +
! Matrix Name !! Description !! Suffix
 +
|-
 +
| {{DataDocLink|DMatrixRMaj}} || Dense Double Real - Row Major || DDRM
 +
|-
 +
| {{DataDocLink|FMatrixRMaj}} || Dense Float Real - Row Major || FDRM
 +
|-
 +
| {{DataDocLink|ZDMatrixRMaj}} || Dense Double Complex - Row Major || ZDRM
 +
|-
 +
| {{DataDocLink|CDMatrixRMaj}} || Dense Float Complex - Row Major || CDRM
 +
|-
 +
| {{DataDocLink|DMatrixSparseCSC}} || Sparse Double Real - Compressed Column || DSCC
 +
|-
 +
| {{DataDocLink|DMatrixSparseTriplet}} || Sparse Double Real - Triplet || DSTL
 +
|-
 +
| {{DocLink|org/ejml/data/DMatrix3x3.html|DMatrix3x3}} || Dense Double Real 3x3 || DDF3
 +
|-
 +
| {{DocLink|org/ejml/data/DMatrix3.html|DMatrix3}} || Dense Double Real 3 || DDF3
 +
|-
 +
| {{DocLink|org/ejml/data/FMatrix3x3.html|FMatrix3x3}} || Dense Float Real 3x3 || FDF3
 +
|-
 +
| {{DocLink|org/ejml/data/FMatrix3.html|FMatrix3}} || Dense Float Real 3 || FDF3
 +
|}
 +
Fixed sized matrix from 2 to 6 are supportedJust replaced the 3 with the desired size''NOTE: In previous versions of EJML the matrix DMatrixRMaj was known as DenseMatrix64F.''
  
While it has a sharper learning curve and takes more time to learn it is the most powerful API.
+
= Matrix Element Accessors =
 
 
* [[Manual#Example Code|List of code examples]]
 
 
 
= Accessors =
 
  
 
* get( row , col )
 
* get( row , col )
Line 23: Line 42:
 
** An iterator that iterates through the sub-matrix by row or by column.
 
** An iterator that iterates through the sub-matrix by row or by column.
  
= Operations =
+
= Operations Classes =
  
Several "Ops" classes provide functions for manipulating DenseMatrix64F and most are contained inside of the org.ejml.ops package.  The list below is provided for real matrices.  For complex matrices add a "C" in front of the name, e.g. CCommonOps.
+
Several "Ops" classes provide functions for manipulating different types of matrices and most are contained inside of the org.ejml.dense.* package, where * is replaced with the matrix structure package type, e.g. row for row-major.  The list below is provided for DMatrixRMaj, other matrix can be found by changing the suffix as discussed above.
  
* CommonOps
+
; {{DocLink|org/ejml/dense/row/CommonOps_DDRM.html|CommonOps_DDRM}} : Provides the most common matrix operations.  
** Provides the most common matrix operations.  
+
; {{DocLink|org/ejml/dense/row/EigenOps_DDRM.html|EigenOps_DDRM}} : Provides operations related to eigenvalues and eigenvectors.
* EigenOps
+
; {{DocLink|org/ejml/dense/row/MatrixFeatures_DDRM.html|MatrixFeatures_DDRM}} : Used to compute various features related to a matrix.
** Provides operations related to eigenvalues and eigenvectors.
+
; {{DocLink|org/ejml/dense/row/NormOps_DDRM.html|NormOps_DDRM}} : Operations for computing different matrix norms.
* MatrixFeatures
+
; {{DocLink|org/ejml/dense/row/SingularOps_DDRM.html|SingularOps_DDRM}} : Operations related to singular value decompositions.
** Used to compute various features related to a matrix.
+
; {{DocLink|org/ejml/dense/row/SpecializedOps_DDRM.html|SpecializedOps_DDRM}} : Grab bag for operations which do not fit in anywhere else.
* NormOps
+
; {{DocLink|org/ejml/dense/row/RandomMatrices_DDRM.html|RandomMatrices_DDRM}} : Used to create different types of random matrices.
** Operations for computing different matrix norms.
 
* SingularOps
 
** Operations related to singular value decompositions.
 
* SpecializedOps
 
** Grab bag for operations which do not fit in anywhere else.
 
* RandomMatrices
 
** Used to create different types of random matrices.
 
  
 
For fixed sized matrices FixedOpsN is provided, where N = 2 to 6.  FixedOpsN is similar in functionality to CommonOps.
 
For fixed sized matrices FixedOpsN is provided, where N = 2 to 6.  FixedOpsN is similar in functionality to CommonOps.

Latest revision as of 07:58, 24 March 2021

The procedural interface in EJML provides access to all of its capabilities and provides much more control over which algorithms are used and when memory is created. The downside to this increased control is the added difficulty in programming, kinda resembles writing in assembly. Code can be made very efficient, but managing all the temporary data structures can be tedious.

The procedural supports all matrix types in EJML and follows a consistent naming pattern across all matrix types. Ops classes end in a suffix that indicate which type of matrix they can process. From the matrix name you can determine the type of element (float,double,real,complex) and it's internal data structure, e.g. row-major or block. In general, almost everyone will want to interact with row major matrices. Conversion to block format is done automatically internally when it becomes advantageous.

Matrix Name Description Suffix
DMatrixRMaj Dense Double Real - Row Major DDRM
FMatrixRMaj Dense Float Real - Row Major FDRM
ZDMatrixRMaj Dense Double Complex - Row Major ZDRM
CDMatrixRMaj Dense Float Complex - Row Major CDRM
DMatrixSparseCSC Sparse Double Real - Compressed Column DSCC
DMatrixSparseTriplet Sparse Double Real - Triplet DSTL
DMatrix3x3 Dense Double Real 3x3 DDF3
DMatrix3 Dense Double Real 3 DDF3
FMatrix3x3 Dense Float Real 3x3 FDF3
FMatrix3 Dense Float Real 3 FDF3

Fixed sized matrix from 2 to 6 are supported. Just replaced the 3 with the desired size. NOTE: In previous versions of EJML the matrix DMatrixRMaj was known as DenseMatrix64F.

Matrix Element Accessors

  • get( row , col )
  • set( row , col , value )
    • Returns or sets the value of an element at the specified row and column.
  • unsafe_get( row , col )
  • unsafe_set( row , col , value )
    • Faster version of get() or set() that does not perform bounds checking.
  • get( index )
  • set( index )
    • Returns or sets the value of an element at the specified index. Useful for vectors and element-wise operations.
  • iterator( boolean rowMajor, int minRow, int minCol, int maxRow, int maxCol )
    • An iterator that iterates through the sub-matrix by row or by column.

Operations Classes

Several "Ops" classes provide functions for manipulating different types of matrices and most are contained inside of the org.ejml.dense.* package, where * is replaced with the matrix structure package type, e.g. row for row-major. The list below is provided for DMatrixRMaj, other matrix can be found by changing the suffix as discussed above.

CommonOps_DDRM
Provides the most common matrix operations.
EigenOps_DDRM
Provides operations related to eigenvalues and eigenvectors.
MatrixFeatures_DDRM
Used to compute various features related to a matrix.
NormOps_DDRM
Operations for computing different matrix norms.
SingularOps_DDRM
Operations related to singular value decompositions.
SpecializedOps_DDRM
Grab bag for operations which do not fit in anywhere else.
RandomMatrices_DDRM
Used to create different types of random matrices.

For fixed sized matrices FixedOpsN is provided, where N = 2 to 6. FixedOpsN is similar in functionality to CommonOps.