Difference between revisions of "Procedural"

From Efficient Java Matrix Library
Jump to navigation Jump to search
(Created page with "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 down...")
 
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 asembly.  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.  For real numbers it takes in [http://ejml.org/javadoc/org/ejml/data/DenseMatrix64F.html DenseMatrix64F] and for complex [http://ejml.org/javadoc/org/ejml/data/CDenseMatrix64F.html CDenseMatrix64F].  These classes themselves only provide very basic operators for accessing elements within a matrix and well as its size and shape.  More complex functions for manipulating DenseMatrix are available in various Ops classes, described below. Internally they store the matrix in a single array using a row-major format.   
+
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 shape.  The complete set of functions for manipulating DenseMatrix are available in various Ops classes, described below.  
 +
 
 +
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 parameter.  This can allow for much faster access and array overhead.  However if fixed sized matrices get too large then performance starts to drop due to what I suppose is CPU caching issues.
  
 
While it has a sharper learning curve and takes more time to learn it is the most powerful API.  
 
While it has a sharper learning curve and takes more time to learn it is the most powerful API.  
Line 23: Line 25:
 
= Operations =
 
= Operations =
  
Several "Ops" classes provide functions for manipulating DenseMatrix64F and most are contained inside of the org.ejml.ops package.
+
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.
  
 
* CommonOps
 
* CommonOps
Line 40: Line 42:
 
** Used to create different types of random matrices.
 
** Used to create different types of random matrices.
  
= Tips for Avoiding "new" =
+
For fixed sized matrices FixedOpsN is provided, where N = 2 to 6. FixedOpsN is similar in functionality to CommonOps.
 
 
TODO fill this out.
 
 
 
* reshape matrices instead of declaring new ones
 
* not all functions recycle memory
 

Revision as of 07:04, 25 March 2015

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 DenseMatrix64F, complex 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 shape. The complete set of functions for manipulating DenseMatrix are available in various Ops classes, described below.

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 parameter. This can allow for much faster access and array overhead. However if fixed sized matrices get too large then performance starts to drop due to what I suppose is CPU caching issues.

While it has a sharper learning curve and takes more time to learn it is the most powerful API.

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

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.

  • CommonOps
    • Provides the most common matrix operations.
  • EigenOps
    • Provides operations related to eigenvalues and eigenvectors.
  • MatrixFeatures
    • Used to compute various features related to a matrix.
  • NormOps
    • 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.