Packageflare.util.math
Interfacepublic interface IMatrix
ImplementorsDenseMatrix, SparseMatrix

Interface for a matrix of real-valued numbers.



Public Properties
 PropertyDefined by
  cols : int
[read-only] The number of columns.
IMatrix
  nnz : int
[read-only] The number of non-zero values.
IMatrix
  rows : int
[read-only] The number of rows.
IMatrix
  sum : Number
[read-only] The sum of all the entries in this matrix.
IMatrix
  sumsq : Number
[read-only] The sum of squares of all the entries in this matrix.
IMatrix
Public Methods
 MethodDefined by
  
Creates a copy of this matrix.
IMatrix
  
get(i:int, j:int):Number
Returns the value at the given indices.
IMatrix
  
init(rows:int, cols:int):void
Initializes the matrix to desired dimensions.
IMatrix
  
like(rows:int, cols:int):IMatrix
Creates a new matrix of the same type.
IMatrix
  
Multiplies this matrix by another.
IMatrix
  
scale(s:Number):void
Multiplies all values in this matrix by the input scalar.
IMatrix
  
set(i:int, j:int, v:Number):Number
Sets the value at the given indices.
IMatrix
  
visit(f:Function):void
Visit all values in the matrix.
IMatrix
  
visitNonZero(f:Function):void
Visit all non-zero values in the matrix.
IMatrix
Property detail
colsproperty
cols:int  [read-only]

The number of columns.

Implementation
    public function get cols():int
nnzproperty 
nnz:int  [read-only]

The number of non-zero values.

Implementation
    public function get nnz():int
rowsproperty 
rows:int  [read-only]

The number of rows.

Implementation
    public function get rows():int
sumproperty 
sum:Number  [read-only]

The sum of all the entries in this matrix.

Implementation
    public function get sum():Number
sumsqproperty 
sumsq:Number  [read-only]

The sum of squares of all the entries in this matrix.

Implementation
    public function get sumsq():Number
Method detail
clone()method
public function clone():IMatrix

Creates a copy of this matrix.

Returns
IMatrix
get()method 
public function get(i:int, j:int):Number

Returns the value at the given indices.

Parameters
i:int — the row index
 
j:int — the column index

Returns
Number — the value at position i,j
init()method 
public function init(rows:int, cols:int):void

Initializes the matrix to desired dimensions. This method also resets all values in the matrix to zero.

Parameters
rows:int — the number of rows in this matrix
 
cols:int — the number of columns in this matrix
like()method 
public function like(rows:int, cols:int):IMatrix

Creates a new matrix of the same type.

Parameters
rows:int — the number of rows in the new matrix
 
cols:int — the number of columns in the new matrix

Returns
IMatrix — a new matrix
multiply()method 
public function multiply(b:IMatrix):IMatrix

Multiplies this matrix by another. The number of rows in this matrix must match the number of columns in the input matrix.

Parameters
b:IMatrix — the matrix to multiply by.

Returns
IMatrix — a new matrix that is the product of this matrix with the input matrix. The new matrix will be of the same type as this one.
scale()method 
public function scale(s:Number):void

Multiplies all values in this matrix by the input scalar.

Parameters
s:Number — the scalar to multiply by.
set()method 
public function set(i:int, j:int, v:Number):Number

Sets the value at the given indices.

Parameters
i:int — the row index
 
j:int — the column index
 
v:Number — the value to set

Returns
Number — the input value v
visit()method 
public function visit(f:Function):void

Visit all values in the matrix. The input function is expected to take three arguments--the row index, the column index, and the cell value--and return a number which then becomes the new value for the cell.

Parameters
f:Function — the function to invoke for each value
visitNonZero()method 
public function visitNonZero(f:Function):void

Visit all non-zero values in the matrix. The input function is expected to take three arguments--the row index, the column index, and the cell value--and return a number which then becomes the new value for the cell.

Parameters
f:Function — the function to invoke for each non-zero value