\seekquarry\yioop\library\classifiersSparseMatrix

A sparse matrix implementation based on an associative array of associative arrays.

A SparseMatrix is mostly a wrapper around an array of arrays, but it keeps track of some extra information such as the true matrix dimensions, and the number of non-zero entries. It also provides a convenience method for partitioning the matrix rows into two new sparse matrices.

Summary

Methods
Properties
Constants
__construct()
rows()
columns()
nonzero()
setRow()
partition()
rewind()
current()
key()
next()
valid()
$m
$n
$nonzero
$data
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$m

$m : integer

The number of rows, regardless of whether or not some are empty.

Type

integer

$n

$n : integer

The number of columns, regardless of whether or not some are empty.

Type

integer

$nonzero

$nonzero : integer

The number of non-zero entries.

Type

integer

$data

$data : array

The actual matrix data, an associative array mapping row indices to associative arrays mapping column indices to their values.

Type

array

Methods

__construct()

__construct(integer  $m, integer  $n) 

Initializes a new sparse matrix with specific dimensions.

Parameters

integer $m

number of rows

integer $n

number of columns

rows()

rows() : \seekquarry\yioop\library\classifiers\number

Accessor method which the number of rows in the matrix

Returns

\seekquarry\yioop\library\classifiers\number —

of rows

columns()

columns() : \seekquarry\yioop\library\classifiers\number

Accessor method which the number of columns in the matrix

Returns

\seekquarry\yioop\library\classifiers\number —

of columns

nonzero()

nonzero() : \seekquarry\yioop\library\classifiers\number

Accessor method which the number of nonzero entries in the matrix

Returns

\seekquarry\yioop\library\classifiers\number —

of nonzero entries

setRow()

setRow(integer  $i, array  $row) 

Sets a particular row of data, keeping track of any new non-zero entries.

Parameters

integer $i

row index

array $row

associative array mapping column indices to values

partition()

partition(array  $a_indices, array  $b_indices) : array

Given two sets of row indices, returns two new sparse matrices consisting of the corresponding rows.

Parameters

array $a_indices

row indices for first new sparse matrix

array $b_indices

row indices for second new sparse matrix

Returns

array —

array with two entries corresponding to the first and second new matrices

rewind()

rewind() 

Resets the iterator

current()

current() : array

Returns the current iterated over row

Returns

array —

current row

key()

key() : integer

Returns the index of the current row

Returns

integer —

index of row

next()

next() : array

Returns the next row to be iterated over

Returns

array —

next row

valid()

valid() : boolean

Whether the current key position is not null

Returns

boolean —

whether it is null or not