Liking cljdoc? Tell your friends :D
Clojure only.

clojure.core.matrix.protocols


broadcast-compatibleclj

(broadcast-compatible a b)

Broadcasts two matrices into identical shapes, coercing to the type of the first matrix. Intended to prepare for elementwise operations. Returns a vector containing the two broadcasted matrices. Throws an error if not possible.

Broadcasts two matrices into identical shapes, coercing to the type of the first matrix.
Intended to prepare for elementwise operations.
Returns a vector containing the two broadcasted matrices.
Throws an error if not possible.
raw docstring

PAddProductcljprotocol

Protocol for add-product operation. Intended to implement a fast version for result = m + a * b

Protocol for add-product operation.
Intended to implement a fast version for result = m + a * b

add-productclj

(add-product m a b)
raw docstring

PAddProductMutablecljprotocol

Protocol for mutable add-product! operation.

Protocol for mutable add-product! operation.

add-product!clj

(add-product! m a b)
raw docstring

PAddScaledcljprotocol

Protocol for add-scaled operation. Intended to implement a fast version for result = m + a * factor

Protocol for add-scaled operation.
Intended to implement a fast version for result = m + a * factor

add-scaledclj

(add-scaled m a factor)
raw docstring

PAddScaledMutablecljprotocol

Protocol for mutable add-scaled! operation.

Protocol for mutable add-scaled! operation.

add-scaled!clj

(add-scaled! m a factor)
raw docstring

PAddScaledProductcljprotocol

Protocol for add-product operation. Intended to implement a fast version for result = m + a * b * factor

Protocol for add-product operation.
Intended to implement a fast version for result = m + a * b * factor

add-scaled-productclj

(add-scaled-product m a b factor)
raw docstring

PAddScaledProductMutablecljprotocol

Protocol for mutable add-product! operation.

Protocol for mutable add-product! operation.

add-scaled-product!clj

(add-scaled-product! m a b factor)
raw docstring

PArrayMetricscljprotocol

Option protocol for quick determination of array matrics

Option protocol for quick determination of array matrics

nonzero-countclj

(nonzero-count m)
raw docstring

PAssignmentcljprotocol

Protocol for assigning values element-wise to mutable arrays.

Protocol for assigning values element-wise to mutable arrays.

assign!clj

(assign! m source)

Sets all the values in an array from a given source. Source may be a scalar or a smaller array that can be broadcast to the shape of m.

Sets all the values in an array from a given source. Source may be a scalar
or a smaller array that can be broadcast to the shape of m.

assign-array!clj

(assign-array! m arr)
(assign-array! m arr start length)

Sets the elements in an array from an Java array source, in row-major order.

Sets the elements in an array from an Java array source, in row-major order.
raw docstring

PBroadcastcljprotocol

Protocol to support broadcasting over one or more dimensions.

Protocol to support broadcasting over one or more dimensions.

broadcastclj

(broadcast m target-shape)

Broadcasts an array over a desired target shape, which should be larger than the current matrix. Dimensions should be matched up according to the last dimension. In order to broadcast sucessfully, the current dimension of the array must be either:

  • of size 1
  • equal to the size of the dimension in the target shape
  • not included in the array (i.e. the target shape has more leading dimensions)

If broadcasting is not possible, an exception must be thrown.

Broadcasting may return either a view with replicated element or a new immutable matrix.

Broadcasts an array over a desired target shape, which should be larger than the current matrix.
Dimensions should be matched up according to the last dimension.
In order to broadcast sucessfully, the current dimension of the array must be either:
 - of size 1
 - equal to the size of the dimension in the target shape
 - not included in the array (i.e. the target shape has more leading dimensions)

If broadcasting is not possible, an exception must be thrown.

Broadcasting may return either a view with replicated element or a new immutable matrix.
raw docstring

PBroadcastCoercecljprotocol

Protocol to broadcast into a given matrix shape and perform coercion in one step.

Equivalent to (coerce m (broadcast-like m a)) but likely to be more efficient.

Protocol to broadcast into a given matrix shape and perform coercion in one step.

Equivalent to (coerce m (broadcast-like m a)) but likely to be more efficient.

broadcast-coerceclj

(broadcast-coerce m a)
raw docstring

PBroadcastLikecljprotocol

Protocol to broadcast into a given matrix shape. May also perform coercion if needed by the implementation.

Protocol to broadcast into a given matrix shape. May also perform coercion if needed by the implementation.

broadcast-likeclj

(broadcast-like m a)
raw docstring

PCoercioncljprotocol

Protocol to coerce a parameter to a format used by a specific implementation. It is up to the implementation to determine what parameter types they support. If the implementation is unable to perform coercion, it must return nil.

Implementations are encouraged to avoid taking a full copy of the data, for performance reasons. It is preferable to use structural sharing with the original data if possible.

If coercion is impossible (e.g. param has an invalid shape or element types) then the implementation may throw an exception, though it may also return nil to get default behaviour, which should implement any expected exceptions.

If an implementation implements coercion via copying, then it is recommended that conversion should be to the most efficient packed representation (i.e. as defined by 'pack')

Implementations must also be able to coerce valid scalar values (presumably via the identity function)

Protocol to coerce a parameter to a format used by a specific implementation. It is
up to the implementation to determine what parameter types they support.
If the implementation is unable to perform coercion, it must return nil.

Implementations are encouraged to avoid taking a full copy of the data, for performance reasons.
It is preferable to use structural sharing with the original data if possible.

If coercion is impossible (e.g. param has an invalid shape or element types) then the
implementation *may* throw an exception, though it may also return nil to get default behaviour,
which should implement any expected exceptions.

If an implementation implements coercion via copying, then it is recommended that conversion
should be to the most efficient packed representation (i.e. as defined by 'pack')

Implementations must also be able to coerce valid scalar values (presumably via the identity function)

coerce-paramclj

(coerce-param m param)

Attempts to coerce param into a matrix format supported by the implementation of matrix m. May return nil if unable to do so, in which case a default implementation can be used.

Attempts to coerce param into a matrix format supported by the implementation of matrix m.
May return nil if unable to do so, in which case a default implementation can be used.
raw docstring

PComputeMatrixcljprotocol

Protocol to compute a matrix by calling a function on each indexed location. The function f will be called as (f x y z ...) for all index values.

Protocol to compute a matrix by calling a function on each indexed location. The function f will be called
as (f x y z ...) for all index values.

compute-matrixclj

(compute-matrix m shape f)
raw docstring

PConversioncljprotocol

Protocol to allow conversion to Clojure-friendly vector format. Optional for implementers, however providing an efficient implementation is strongly encouraged to enable fast interop with Clojure vectors.

Protocol to allow conversion to Clojure-friendly vector format. Optional for implementers,
however providing an efficient implementation is strongly encouraged to enable fast interop 
with Clojure vectors.

convert-to-nested-vectorsclj

(convert-to-nested-vectors m)
raw docstring

PDimensionInfocljprotocol

Protocol to return standard dimension information about an array. dimensionality and dimension-count are mandatory for implementations

Protocol to return standard dimension information about an array.
dimensionality and dimension-count are mandatory for implementations

dimension-countclj

(dimension-count m dimension-number)

Returns the size of a specific dimension. Must throw an exception if the array does not have the specified dimension.

Returns the size of a specific dimension. Must throw an exception if the array does not
have the specified dimension.

dimensionalityclj

(dimensionality m)

Returns the number of dimensions of an array

Returns the number of dimensions of an array

get-shapeclj

(get-shape m)

Returns the shape of the array, typically as a Java array or sequence of dimension sizes. Implementations are free to choose what type is used to represent the shape, but it must contain only integer values and be traversable as a sequence via clojure.core/seq

Returns the shape of the array, typically as a Java array or sequence of dimension sizes.
Implementations are free to choose what type is used to represent the shape, but it must
contain only integer values and be traversable as a sequence via clojure.core/seq

is-scalar?clj

(is-scalar? m)

Tests whether an object is a scalar value, i.e. a value that can exist at a specific position in an array.

Tests whether an object is a scalar value, i.e. a value that can exist at a
specific position in an array.

is-vector?clj

(is-vector? m)

Tests whether an object is a vector (1D array)

Tests whether an object is a vector (1D array)
raw docstring

PDoubleArrayOutputcljprotocol

Protocol for getting data as a double array

Protocol for getting data as a double array

as-double-arrayclj

(as-double-array m)

Returns the internal double array used by m. If no such array is used, returns nil. Provides an opportunity to avoid copying the internal array.

Returns the internal double array used by m. If no such array is used, returns nil.
Provides an opportunity to avoid copying the internal array.

to-double-arrayclj

(to-double-array m)

Returns a double array containing the values of m in row-major order. May or may not be the internal double array used by m, depending on the implementation.

Returns a double array containing the values of m in row-major order. May or may not be
the internal double array used by m, depending on the implementation.
raw docstring

PElementCountcljprotocol

Protocol to return the total count of elements in matrix. Result may be any integer type, typically a java.lang.Long

Protocol to return the total count of elements in matrix. Result may be any integer type,
typically a java.lang.Long

element-countclj

(element-count m)
raw docstring

persistent-vector-coerceclj

(persistent-vector-coerce x)

PExponentcljprotocol

Protocol to support the 'pow' function. Should raise every element of a matrix to a given exponent. Default implementation uses Java's Math/pow function which is appropriate for double values: arrays supporting arbitrary precision numbers or complex types will need to provide their own implementation.

Protocol to support the 'pow' function. Should raise every element of a matrix to a
given exponent. Default implementation uses Java's Math/pow function which is appropriate for
double values: arrays supporting arbitrary precision numbers or complex types will need to
provide their own implementation.

element-powclj

(element-pow m exponent)
raw docstring

PFunctionalOperationscljprotocol

Protocol to allow functional-style operations on matrix elements.

Protocol to allow functional-style operations on matrix elements.

element-mapclj

(element-map m f)
(element-map m f a)
(element-map m f a more)

Maps f over all elements of m (and optionally other matrices), returning a new matrix

Maps f over all elements of m (and optionally other matrices), returning a new matrix

element-map!clj

(element-map! m f)
(element-map! m f a)
(element-map! m f a more)

Maps f over all elements of m (and optionally other matrices), mutating the elements of m in place. Must throw an exception if m is not mutable.

Maps f over all elements of m (and optionally other matrices), mutating the elements of m in place.
Must throw an exception if m is not mutable.

element-reduceclj

(element-reduce m f)
(element-reduce m f init)

Reduces with the function f over all elements of m.

Reduces with the function f over all elements of m.

element-seqclj

(element-seq m)

Must return a sequence containing all elements of the matrix, in row-major order.

Must return a sequence containing all elements of the matrix, in row-major order.
raw docstring

PGenericOperationscljprotocol

Protocol for returning the generic numerical functions of a matrix implementation

Protocol for returning the generic numerical functions of a matrix implementation

generic-addclj

(generic-add m)

Generic 'add' function for numerical values. Must satisfy (equals x (add zero x)).

Generic 'add' function for numerical values. Must satisfy (equals x (add zero x)).

generic-divclj

(generic-div m)

Generic 'div' function for numerical values.

Generic 'div' function for numerical values.

generic-mulclj

(generic-mul m)

Generic 'mul' function for numerical values. Must satisfy (equals x (mul one x)).

Generic 'mul' function for numerical values. Must satisfy (equals x (mul one x)).

generic-negateclj

(generic-negate m)

Generic 'negate' function for numerical values.

Generic 'negate' function for numerical values.
raw docstring

PGenericValuescljprotocol

Protocol for returning the generic/default values of a matrix implementation

Protocol for returning the generic/default values of a matrix implementation

generic-oneclj

(generic-one m)

Generic 'one' value for numerical arrays. Must satisfy (equals m (mul m one)).

Generic 'one' value for numerical arrays. Must satisfy (equals m (mul m one)).

generic-valueclj

(generic-value m)

Generic value for a new array. Likely to be zero or nil.

Generic value for a new array. Likely to be zero or nil.

generic-zeroclj

(generic-zero m)

Generic 'zero' value for numerical arrays. Must satisfy (equals m (add m zero)).

Generic 'zero' value for numerical arrays. Must satisfy (equals m (add m zero)).
raw docstring

PImmutableAssignmentcljprotocol

Protocol for assigning values element-wise to an array, broadcasting as needed.

Protocol for assigning values element-wise to an array, broadcasting as needed.

assignclj

(assign m source)

Sets all the values in an array from a given source. Source may be a scalar or a smaller array that can be broadcast to the shape of m.

Sets all the values in an array from a given source. Source may be a scalar
or a smaller array that can be broadcast to the shape of m.
raw docstring

PImmutableMatrixConstructioncljprotocol

Protocol for creating an immutable copy of a matrix. If implemented, must return a fully immutable copy of the given matrix.

The default implementation will attempt to choose a suitable immutable matrix implementation.

Protocol for creating an immutable copy of a matrix. If implemented, must return a fully immutable
copy of the given matrix.

The default implementation will attempt to choose a suitable immutable matrix implementation.

immutable-matrixclj

(immutable-matrix m)
raw docstring

PImplementationcljprotocol

Protocol for general implementation functionality. Required to support implementation metadata and matrix construction.

Protocol for general implementation functionality. Required to support implementation metadata and
matrix construction.

construct-matrixclj

(construct-matrix m data)

Returns a new matrix containing the given data. data should be in the form of either nested sequences or a valid existing matrix

Returns a new matrix containing the given data. data should be in the form of either
nested sequences or a valid existing matrix

implementation-keyclj

(implementation-key m)

Returns a keyword representing this implementation. Each implementation should have one unique key.

Returns a keyword representing this implementation.
Each implementation should have one unique key.

meta-infoclj

(meta-info m)

Returns meta-information on the implementation. It is expected that at least an element :doc containing a string describing an implementation is provided.

Returns meta-information on the implementation. It is expected that
at least an element :doc containing a string describing an implementation
is provided.

new-matrixclj

(new-matrix m rows columns)

Returns a new matrix (regular 2D matrix) with the given number of rows and columns, filled with numeric zero.

Returns a new matrix (regular 2D matrix) with the given number of rows and columns, filled with numeric zero.

new-matrix-ndclj

(new-matrix-nd m shape)

Returns a new general matrix of the given shape. Shape must be a sequence of dimension sizes.

Returns a new general matrix of the given shape.
Shape must be a sequence of dimension sizes.

new-vectorclj

(new-vector m length)

Returns a new vector (1D column matrix) of the given length, filled with numeric zero.

Returns a new vector (1D column matrix) of the given length, filled with numeric zero.

supports-dimensionality?clj

(supports-dimensionality? m dimensions)

Returns true if the implementation supports matrices with the given number of dimensions.

Returns true if the implementation supports matrices with the given number of dimensions.
raw docstring

PIndexedAccesscljprotocol

Protocol for indexed read access to arrays, matrices and vectors. Indexing values can be assumed to be integers. indexes may be any sequence or Java array of index values.

Protocol for indexed read access to arrays, matrices and vectors. Indexing values can
be assumed to be integers. indexes may be any sequence or Java array of index values.

get-1dclj

(get-1d m row)

get-2dclj

(get-2d m row column)

get-ndclj

(get-nd m indexes)
raw docstring

PIndexedSettingcljprotocol

Protocol for indexed 'setter' operations. These are like Clojure's 'assoc' function, i.e. they return an updated copy of the original array, which is itself unchanged. Must be supported for any immutable array type.

Protocol for indexed 'setter' operations. These are like Clojure's 'assoc'
function, i.e. they return an updated copy of the original array, which is itself unchanged.
Must be supported for any immutable array type.

is-mutable?clj

(is-mutable? m)

Returns true if the matrix is mutable and therefore supports direct mutable operations, e.g. add!

Returns true if the matrix is mutable and therefore supports direct mutable operations, e.g. add!

set-1dclj

(set-1d m row v)

set-2dclj

(set-2d m row column v)

set-ndclj

(set-nd m indexes v)
raw docstring

PIndexedSettingMutablecljprotocol

Protocol for indexed mutable setter access to matrices and vectors. Must be supported for any mutable matrix type.

Protocol for indexed mutable setter access to matrices and vectors.
Must be supported for any mutable matrix type.

set-1d!clj

(set-1d! m row v)

set-2d!clj

(set-2d! m row column v)

set-nd!clj

(set-nd! m indexes v)
raw docstring

PMathsFunctionscljprotocol

Protocol to support mathematic functions applied element-wise to a numerical array

Protocol to support mathematic functions applied element-wise to a numerical array

to-radiansclj

(to-radians m)

logclj

(log m)

acosclj

(acos m)

to-degreesclj

(to-degrees m)

floorclj

(floor m)

tanhclj

(tanh m)

ceilclj

(ceil m)

atanclj

(atan m)

cosclj

(cos m)

log10clj

(log10 m)

tanclj

(tan m)

cbrtclj

(cbrt m)

sqrtclj

(sqrt m)

expclj

(exp m)

coshclj

(cosh m)

asinclj

(asin m)

roundclj

(round m)

absclj

(abs m)

sinhclj

(sinh m)

sinclj

(sin m)

signumclj

(signum m)
raw docstring

PMathsFunctionsMutablecljprotocol

Protocol to support mutable mathematic functions applied element-wise to a numerical array

Protocol to support mutable mathematic functions applied element-wise to a numerical array

sqrt!clj

(sqrt! m)

asin!clj

(asin! m)

cos!clj

(cos! m)

ceil!clj

(ceil! m)

atan!clj

(atan! m)

to-radians!clj

(to-radians! m)

abs!clj

(abs! m)

log!clj

(log! m)

cosh!clj

(cosh! m)

sin!clj

(sin! m)

tan!clj

(tan! m)

exp!clj

(exp! m)

to-degrees!clj

(to-degrees! m)

cbrt!clj

(cbrt! m)

round!clj

(round! m)

signum!clj

(signum! m)

acos!clj

(acos! m)

sinh!clj

(sinh! m)

tanh!clj

(tanh! m)

floor!clj

(floor! m)

log10!clj

(log10! m)
raw docstring

PMatrixAddcljprotocol

Protocol to support addition and subtraction on arbitrary matrices. These are elementwise operations that should support broadcasting.

Protocol to support addition and subtraction on arbitrary matrices. 
These are elementwise operations that should support broadcasting.

matrix-addclj

(matrix-add m a)

matrix-subclj

(matrix-sub m a)
raw docstring

PMatrixAddMutablecljprotocol

Protocol to support mutable addition and subtraction

Protocol to support mutable addition and subtraction

matrix-add!clj

(matrix-add! m a)

matrix-sub!clj

(matrix-sub! m a)
raw docstring

PMatrixCloningcljprotocol

Protocol for cloning a matrix value. The new clone must be mutable if the original matrix is mutable, i.e. mutating the clone must not affect the original. The copy should be shallow, if applicable.

Protocol for cloning a matrix value. The new clone must be mutable if the original
matrix is mutable, i.e. mutating the clone must not affect the original. The copy should be shallow, if applicable.

cloneclj

(clone m)

Returns a clone of an array. Must be a new independent (non-view) instance if the array is mutable.

Returns a clone of an array. Must be a new independent (non-view)
instance if the array is mutable.
raw docstring

PMatrixDividecljprotocol

Protocol to support element-wise division operator. One-arg version returns the reciprocal of all elements.

Protocol to support element-wise division operator.
One-arg version returns the reciprocal of all elements.

element-divideclj

(element-divide m)
(element-divide m a)
raw docstring

PMatrixDivideMutablecljprotocol

Protocol to support mutable element-wise division operater. One-arg version returns the reciprocal of all elements.

Protocol to support mutable element-wise division operater.
One-arg version returns the reciprocal of all elements.

element-divide!clj

(element-divide! m)
(element-divide! m a)
raw docstring

PMatrixEqualitycljprotocol

Protocol for numerical array equality operations.

Protocol for numerical array equality operations.

matrix-equalsclj

(matrix-equals a b)

Return true if a equals b, i.e. if a and b are have the same shape and all elements are equal. Must use numerical value comparison on numbers (==) to account for matrices that may hold a mix of numercial types (e.g. java.lang.Long and java.lang.Double). Implementations that only support doubles should use Number.doubleValue() to get a numeric value to compare. May throw an exception if the matrices are non-numeric

Return true if a equals b, i.e. if a and b are have the same shape and all elements are equal.
Must use numerical value comparison on numbers (==) to account for matrices that may hold a mix of
numercial types (e.g. java.lang.Long and java.lang.Double). Implementations that only support doubles
should use Number.doubleValue() to get a numeric value to compare.
May throw an exception if the matrices are non-numeric
raw docstring

PMatrixEqualityEpsiloncljprotocol

Protocol for numerical array equality operations with a specified tolerance.

Protocol for numerical array equality operations with a specified tolerance.

matrix-equals-epsilonclj

(matrix-equals-epsilon a b eps)

As matrix-equals, but provides a numerical tolerance for equality testing.

As matrix-equals, but provides a numerical tolerance for equality testing.
raw docstring

PMatrixMultiplycljprotocol

Protocol to support matrix multiplication on an arbitrary matrix, vector or scalar.

Implementation may return nil if the implementation does not support one of the parameters, in which case a more general operation will be attempted.

Protocol to support matrix multiplication on an arbitrary matrix, vector or scalar.

Implementation may return nil if the implementation does not support one of the parameters, in
which case a more general operation will be attempted.

element-multiplyclj

(element-multiply m a)

matrix-multiplyclj

(matrix-multiply m a)
raw docstring

PMatrixMultiplyMutablecljprotocol

Protocol to support mutable matrix multiplication on an arbitrary matrix, vector or scalar

Protocol to support mutable matrix multiplication on an arbitrary matrix, vector or scalar

element-multiply!clj

(element-multiply! m a)

matrix-multiply!clj

(matrix-multiply! m a)
raw docstring

PMatrixMutableScalingcljprotocol

Protocol to support mutable array scaling by scalar values.

Protocol to support mutable array scaling by scalar values.

pre-scale!clj

(pre-scale! m factor)

scale!clj

(scale! m factor)
raw docstring

PMatrixOpscljprotocol

Protocol to support common 2D numerical matrix operations

Protocol to support common 2D numerical matrix operations

determinantclj

(determinant m)

Returns the determinant of a matrix.

Returns the determinant of a matrix.

inverseclj

(inverse m)

Returns the invese of a matrix. Should throw an exception if m is not invertible.

Returns the invese of a matrix. Should throw an exception if m is not invertible.

traceclj

(trace m)

Returns the trace of a matrix (sum of elements on main diagonal. Must throw an error if the matrix is not square (i.e. all dimensions sizes are equal)

Returns the trace of a matrix (sum of elements on main diagonal.
Must throw an error if the matrix is not square (i.e. all dimensions sizes are equal)
raw docstring

PMatrixPredicatescljprotocol

Protocol for matrix predicates like identity-matrix? or zero-matrix?

Protocol for matrix predicates like identity-matrix? or zero-matrix?

identity-matrix?clj

(identity-matrix? m)

returns true if the matrix m is an identity-matrix

returns true if the matrix m is an identity-matrix

loop-symmetric?clj

(loop-symmetric? m)

FOR TESTING ONLY. returns true if matrix m is symmetric

FOR TESTING ONLY. returns true if matrix m is symmetric

symmetric?clj

(symmetric? m)

returns true if matrix m is symmetric

returns true if matrix m is symmetric

zero-matrix?clj

(zero-matrix? m)

returns true if all the elements of matrix m are zeros

returns true if all the elements of matrix m are zeros
raw docstring

PMatrixProductscljprotocol

Protocol for general inner and outer products of arrays. Products should use + and * as normally defined for numerical types

Protocol for general inner and outer products of arrays.
Products should use + and * as normally defined for numerical types

inner-productclj

(inner-product m a)

outer-productclj

(outer-product m a)
raw docstring

PMatrixRankcljprotocol

Protocol to support computing the rank (number of linearly independent rows) in a matrix

Protocol to support computing the rank (number of linearly independent rows) in a matrix

rankclj

(rank m)

Returns the rank of a matrix

Returns the rank of a matrix
raw docstring

PMatrixScalingcljprotocol

Protocol to support numerical array scaling by scalar values. Provided because array classes may have efficient specialised scaling operaions.

Works according the the default definition of multiplication for the matrix class (usually numerical, i.e. equivalent to clojure.core/+)

Protocol to support numerical array scaling by scalar values. Provided because array classes may have
efficient specialised scaling operaions.

Works according the the default definition of multiplication for the matrix class
(usually numerical, i.e. equivalent to clojure.core/+)

pre-scaleclj

(pre-scale m a)

Pre-multiplies the array with the scalar. This is the same as scale for arrays where multiplication is commutative, but may be different for special kinds of scalars.

Pre-multiplies the array with the scalar. This is the same as scale for arrays
where multiplication is commutative, but may be different for special kinds of scalars.

scaleclj

(scale m a)

Multiplies a array by the scalar value a,

Multiplies a array by the scalar value a, 
raw docstring

PMatrixSlicescljprotocol

Protocol to support getting slices of an array. If implemented, must return either a view, a scalar or an immutable sub-matrix: it must not return copied data. i.e. making a full copy must be avoided.

Protocol to support getting slices of an array.  If implemented, must return either a view, a scalar
or an immutable sub-matrix: it must *not* return copied data. i.e. making a full copy must be avoided.

get-columnclj

(get-column m i)

get-major-sliceclj

(get-major-slice m i)

get-rowclj

(get-row m i)

get-sliceclj

(get-slice m dimension i)
raw docstring

PMatrixSubComponentscljprotocol

Protocol for picking out subsections of a 2D matrix. Should return a mutable view if possible. The default implementation creates a new vector containing the diagonal values.

Protocol for picking out subsections of a 2D matrix. Should return a mutable view if possible.
The default implementation creates a new vector containing the diagonal values.

main-diagonalclj

(main-diagonal m)
raw docstring

PMutableFillcljprotocol

fill!clj

(fill! m value)

Fills the array with the given scalar value.

Fills the array with the given scalar value.

PMutableMatrixConstructioncljprotocol

Protocol for creating a mutable copy of a matrix. If implemented, must return either a fully mutable copy of the given matrix, or nil if not possible.

The default implementation will attempt to choose a suitable mutable matrix implementation.

Protocol for creating a mutable copy of a matrix. If implemented, must return either a fully mutable
copy of the given matrix, or nil if not possible.

The default implementation will attempt to choose a suitable mutable matrix implementation.

mutable-matrixclj

(mutable-matrix m)
raw docstring

PMutableVectorOpscljprotocol

Protocol for mutable versions of common vector operations

Protocol for mutable versions of common vector operations

normalise!clj

(normalise! a)
raw docstring

PNegationcljprotocol

negateclj

(negate m)

Returns a new numerical array with all elements negated.

Returns a new numerical array with all elements negated.

PNumericalcljprotocol

Protocol for identifying numerical arrays. Should return true if every element in the array is a valid numerical value.

Protocol for identifying numerical arrays. Should return true if every element in the
array is a valid numerical value.

numerical?clj

(numerical? m)

Returns true if the array is numerical.

Returns true if the array is numerical.
raw docstring

PObjectArrayOutputcljprotocol

Protocol for getting data as an object array

Protocol for getting data as an object array

as-object-arrayclj

(as-object-array m)

Returns the internal object array used by m. If no such array is used, returns nil. Provides an opportunity to avoid copying the internal array.

Returns the internal object array used by m. If no such array is used, returns nil.
Provides an opportunity to avoid copying the internal array.

to-object-arrayclj

(to-object-array m)

Returns an object array containing the values of m in row-major order. May or may not be the internal object array used by m, depending on the implementation.

Returns an object array containing the values of m in row-major order. May or may not be
the internal object array used by m, depending on the implementation.
raw docstring

PPackcljprotocol

Protocol to efficiently pack an array, according to the most efficient representation for a given implementation.

Definition of pack is up to the implementation to interpret, but the general rules are:

  1. Must not change the value of the array for comparison purposes
  2. Must not change the shape of the array
  3. May preserve sparse representation
  4. Should convert most efficient format for common operations (e.g. mget, inner-product)
Protocol to efficiently pack an array, according to the most efficient representation for a given 
implementation.

Definition of pack is up to the implementation to interpret, but the general rules are:
1. Must not change the value of the array for comparison purposes
2. Must not change the shape of the array
3. May preserve sparse representation
4. Should convert most efficient format for common operations (e.g. mget, inner-product)

packclj

(pack m)
raw docstring

PPermutationMatrixcljprotocol

Protocol for construction of a permutation matrix.

Protocol for construction of a permutation matrix.

permutation-matrixclj

(permutation-matrix m permutation)
raw docstring

PReshapingcljprotocol

Protocol to reshape matrices. Should support any new shape allowed by the implementation. Must preserve row-major ordering of matrix elements. If the original matrix is mutable, must return a new mutable copy of data. If the new shape has less elements than the original shape, it is OK to truncate the remaining elements. If the new shape requires more elements than the original shape, should throw an exception.

Protocol to reshape matrices. Should support any new shape allowed by the implementation.
Must preserve row-major ordering of matrix elements.
If the original matrix is mutable, must return a new mutable copy of data.
If the new shape has less elements than the original shape, it is OK to truncate the remaining elements.
If the new shape requires more elements than the original shape, should throw an exception.

reshapeclj

(reshape m shape)
raw docstring

PRotatecljprotocol

Rotates an array along a specified dimension by the given number of places.

Rotating a dimension that does not exist has no effect on the array.

Rotates an array along a specified dimension by the given number of places.

Rotating a dimension that does not exist has no effect on the array.

rotateclj

(rotate m dim places)
raw docstring

PRotateAllcljprotocol

Rotates an array using the specified shifts for each dimension.

shifts may be any sequence of iteger shift amounts.

Rotates an array using the specified shifts for each dimension.

shifts may be any sequence of iteger shift amounts.

rotate-allclj

(rotate-all m shifts)
raw docstring

PRowColMatrixcljprotocol

Protocol to support construction of row and column matrices from 1D vectors.

A vector of length N should be converted to a 1xN or Nx1 matrix respectively.

Should throw an error if the data is not a 1D vector

Protocol to support construction of row and column matrices from 1D vectors.

A vector of length N should be converted to a 1xN or Nx1 matrix respectively.   

Should throw an error if the data is not a 1D vector

column-matrixclj

(column-matrix m data)

row-matrixclj

(row-matrix m data)
raw docstring

PRowOperationscljprotocol

Protocol for elementary row operations

Protocol for elementary row operations

add-rowclj

(add-row m i j k)

Returns a new matrix with row i added to row j times k

Returns a new matrix with row i added to row j times k

multiply-rowclj

(multiply-row m i k)

Returns a new matrix with row i multiplied by k

Returns a new matrix with row i multiplied by k

swap-rowsclj

(swap-rows m i j)

Returns a new matrix with rows i and j swapped

Returns a new matrix with rows i and j swapped
raw docstring

PRowSettingcljprotocol

Protocol for row setting. Should set a dimension 0 (row) slice to thegiven row value.

Protocol for row setting. Should set a dimension 0 (row) slice to thegiven row value.

set-rowclj

(set-row m i row)

set-row!clj

(set-row! m i row)
raw docstring

PSameShapecljprotocol

Protocol to test if two arrays have the same shape. Implementations may have an optimised method for shape equality tests, and this is a frequently required operations so it may make sense to provide an optimised implementation.

Protocol to test if two arrays have the same shape. Implementations may have an optimised 
method for shape equality tests, and this is a frequently required operations so it may
make sense to provide an optimised implementation.

same-shape?clj

(same-shape? a b)
raw docstring

PSliceJoincljprotocol

Protocol for concatenating / joining arrays.

Protocol for concatenating / joining arrays.

joinclj

(join m a)

Concatenates a to m, along the major slice dimension

Concatenates a to m, along the major slice dimension
raw docstring

PSliceSeqcljprotocol

Returns the row-major slices of the array as a sequence.

These must be views or immutable sub-arrays for higher order slices, or scalars for the slices of a 1D vector.

The default implementation uses get-major-slice-view to obtain the slices.

Returns the row-major slices of the array as a sequence. 

These must be views or immutable sub-arrays for higher order slices, or scalars
for the slices of a 1D vector.

The default implementation uses get-major-slice-view to obtain the slices.

get-major-slice-seqclj

(get-major-slice-seq m)

Gets a sequence of all major array slices

Gets a sequence of all major array slices
raw docstring

PSliceViewcljprotocol

Protocol for quick view access into a row-major slices of an array. If implemented, must return either a view or an immutable sub-matrix: it must not return copied data.

If the matrix is mutable, it must return a mutable view.

The default implementation creates a wrapper view.

Protocol for quick view access into a row-major slices of an array. If implemented, must return
either a view or an immutable sub-matrix: it must *not* return copied data.

If the matrix is mutable, it must return a mutable view.

The default implementation creates a wrapper view.

get-major-slice-viewclj

(get-major-slice-view m i)

Gets a view of a major array slice

Gets a view of a major array slice
raw docstring

PSliceViewSeqcljprotocol

Returns the row-major slice views of the array.

These must be arrays if the array is mutable, i.e. slices of a 1D vector must be 0-dimensional mutable arrays.

Returns the row-major slice views of the array. 

These must be arrays if the array is mutable, i.e. slices of a 1D vector
must be 0-dimensional mutable arrays.

get-major-slice-view-seqclj

(get-major-slice-view-seq m)

Gets a sequence of all major array slices

Gets a sequence of all major array slices
raw docstring

PSparseArraycljprotocol

Protocol for determining if an array is sparse

Protocol for determining if an array is sparse

is-sparse?clj

(is-sparse? m)
raw docstring

PSpecialisedConstructorscljprotocol

Protocol for construction of special matrices.

Protocol for construction of special matrices.

diagonal-matrixclj

(diagonal-matrix m diagonal-values)

Create a diagonal matrix with the specified leading diagonal values

Create a diagonal matrix with the specified leading diagonal values

identity-matrixclj

(identity-matrix m dims)

Create a 2D identity matrix with the given number of dimensions

Create a 2D identity matrix with the given number of dimensions
raw docstring

PSquarecljprotocol

Protocol to support element-wise squaring of a numerical array.

Protocol to support element-wise squaring of a numerical array.

squareclj

(square m)
raw docstring

PSubMatrixcljprotocol

Protocol to get a subarray of another array. dim-ranges should be a sequence of [start len] pairs, one for each dimension. If a pair is nil, it should be interpreted to take the whole dimension.

Returning a mutable view is preferred, if the implementation supports this.

Protocol to get a subarray of another array. dim-ranges should be a sequence of [start len]
pairs, one for each dimension. If a pair is nil, it should be interpreted to take the whole dimension.

Returning a mutable view is preferred, if the implementation supports this.

submatrixclj

(submatrix d dim-ranges)
raw docstring

PSubVectorcljprotocol

Protocol for getting a sub-vector view of a vector. Must return a mutable view if the original vector is mutable. Should throw an exception if the specified subvector is out of bounds for the target vector.

Protocol for getting a sub-vector view of a vector. Must return a mutable view
if the original vector is mutable. Should throw an exception if the specified
subvector is out of bounds for the target vector.

subvectorclj

(subvector m start length)
raw docstring

PSummablecljprotocol

Protocol to support the summing of all elements in an array. The array must hold numeric values only, or an exception will be thrown.

Protocol to support the summing of all elements in an array.
The array must hold numeric values only, or an exception will be thrown.

element-sumclj

(element-sum m)
raw docstring

PTransposecljprotocol

Protocol for array transpose operation

Protocol for array transpose operation

transposeclj

(transpose m)

Returns the transpose of a matrix. Equivalent to reversing the "shape". Note that:

  • The transpose of a scalar is the same scalar
  • The transpose of a 1D vector is the same 1D vector
  • The transpose of a 2D matrix swaps rows and columns
Returns the transpose of a matrix. Equivalent to reversing the "shape".
Note that:
- The transpose of a scalar is the same scalar
- The transpose of a 1D vector is the same 1D vector
- The transpose of a 2D matrix swaps rows and columns
raw docstring

PTransposeInPlacecljprotocol

Protocol for mutable 2D matrix transpose in place

Protocol for mutable 2D matrix transpose in place

transpose!clj

(transpose! m)

Transposes a mutable 2D matrix in place

Transposes a mutable 2D matrix in place
raw docstring

PTypeInfocljprotocol

Protocol for querying the type of matrix elements. If not provided, the default implementation will return java.lang.Object, and the matrix object must accept any type of value. If a matrix is primitive-backed, it should return the appropriate primitive type e.g. Double/TYPE.

Protocol for querying the type of matrix elements. If not provided, the default implementation will
return java.lang.Object, and the matrix object must accept any type of value.
If a matrix is primitive-backed, it should return the appropriate primitive type e.g. Double/TYPE.

element-typeclj

(element-type m)
raw docstring

PValidateShapecljprotocol

Optional protocol to validate the shape of a matrix. If the matrix has an incorrect shape, should throw an error. Otherwise it should return the correct shape.

Optional protocol to validate the shape of a matrix. If the matrix has an incorrect shape, should 
throw an error. Otherwise it should return the correct shape.

validate-shapeclj

(validate-shape m)
raw docstring

PValueEqualitycljprotocol

Protocol for comparing two arrays, with the semantics of clojure.core/=. Returns false if the arrays are not of equal shape, or if any elements are not equal.

Protocol for comparing two arrays, with the semantics of clojure.core/=.
Returns false if the arrays are not of equal shape, or if any elements are not equal.

value-equalsclj

(value-equals m a)
raw docstring

PVectorCrosscljprotocol

cross-productclj

(cross-product a b)

Cross product of two vectors

Cross product of two vectors

cross-product!clj

(cross-product! a b)

Calculate cross product of two vectors, storing the result in the first vector

Calculate cross product of two vectors, storing the result in the first vector

PVectorDistancecljprotocol

distanceclj

(distance a b)

Euclidean distance of two vectors.

Euclidean distance of two vectors.

PVectorisablecljprotocol

Protocol to return an array as a flattened vector of all elements. Implementations are encouraged to avoid taking a full copy of all data (e.g. by using structural sharing or views).

Protocol to return an array as a flattened vector of all elements.
Implementations are encouraged to avoid taking a full copy of all data
(e.g. by using structural sharing or views).

to-vectorclj

(to-vector m)

Returns an array as a single flattened vector

Returns an array as a single flattened vector
raw docstring

PVectorOpscljprotocol

Protocol to support common numerical vector operations.

Protocol to support common numerical vector operations.

lengthclj

(length a)

Euclidian length of a vector.

Euclidian length of a vector.

length-squaredclj

(length-squared a)

Squared Euclidean length of a vector.

Squared Euclidean length of a vector.

normaliseclj

(normalise a)

Returns a new vector, normalised to length 1.0

Returns a new vector, normalised to length 1.0

vector-dotclj

(vector-dot a b)

Numerical dot product of two vectors. Must return a scalar value if the two parameters are vectors of equal length.

If the vectors are of unequal length, should throw an exception (however returning nil is also acceptable).

Otherwise the implementation may optionally either return nil or compute a higher dimensional inner-product (if it is able to do so).

Numerical dot product of two vectors. Must return a scalar value if the two parameters are 
vectors of equal length.

If the vectors are of unequal length, should throw an exception (however returning nil is
also acceptable).

Otherwise the implementation may optionally either return nil or compute a higher dimensional 
inner-product (if it is able to do so).
raw docstring

PVectorTransformcljprotocol

Protocol to support transformation of a vector to another vector. Is equivalent to matrix multiplication when 2D matrices are used as transformations. But other transformations are possible, e.g. affine transformations.

A transformation need not be a core.matrix matrix: other types are permissible

Protocol to support transformation of a vector to another vector.
Is equivalent to matrix multiplication when 2D matrices are used as transformations.
But other transformations are possible, e.g. affine transformations.

A transformation need not be a core.matrix matrix: other types are permissible

vector-transformclj

(vector-transform t v)

Transforms a vector

Transforms a vector

vector-transform!clj

(vector-transform! t v)

Transforms a vector in place - mutates the vector argument

Transforms a vector in place - mutates the vector argument
raw docstring

PVectorViewcljprotocol

as-vectorclj

(as-vector m)

Returns a view of an array as a single flattened vector. May return the vector itself if it is already a 1D vector.

Returns a view of an array as a single flattened vector. May return the vector itself
if it is already a 1D vector.

PZeroCountcljprotocol

Protocol for counting the number of zeros in an array

Protocol for counting the number of zeros in an array

zero-countclj

(zero-count m)
raw docstring

PZeroDimensionAccesscljprotocol

Protocol for accessing the scalar value in zero-dimensional arrays. Zero dimensional arrays differ from scalar values in the following two senses:

  • They may be mutable (in which case set-0d! is expected to work)
  • They are not considered themselves to be scalars. Hence you must use get-0d to access the contained scalar value
Protocol for accessing the scalar value in zero-dimensional arrays. Zero dimensional arrays differ
from scalar values in the following two senses:
 - They may be mutable (in which case set-0d! is expected to work)
 - They are not considered themselves to be scalars. Hence you must use get-0d to access the
   contained scalar value

get-0dclj

(get-0d m)

set-0d!clj

(set-0d! m value)
raw docstring

PZeroDimensionConstructioncljprotocol

new-scalar-arrayclj

(new-scalar-array m)
(new-scalar-array m value)

Construct a new zero-dimensional array with the specified scalar value (zero if not specified)

Construct a new zero-dimensional array with the specified scalar value (zero if not specified)

PZeroDimensionSetcljprotocol

Protocol for setting the scalar value in zero-dimensional arrays.

Protocol for setting the scalar value in zero-dimensional arrays.

set-0dclj

(set-0d m value)

Sets the scalar value in a 0-d array, returning a new 0-d array

Sets the scalar value in a 0-d array, returning a new 0-d array
raw docstring

same-shapes?clj

(same-shapes? arrays)

Returns true if a sequence of arrays all have the same shape.

Returns true if a sequence of arrays all have the same shape.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close