uncomplicate.neanderthal.block

Convenient functions for accessing the memory block that holds vector space’s data and inquire about its structure. This is less useful for application code, which should use linear algebra functions instead of snooping inside, but is indispensible in code that extends Neanderthal’s functionality.

buffer

(buffer x)

Accesses the underlying data buffer. Typically returns the JavaCPP pointer to a memory block, or a technology-specific wrapper that serves an equivalent function. You might need to further call extract on it. See the implementation of Neanderthal’s backends for real-world examples. This is trivial on the surface, but many traps wait in disguise; please study Clojure CPP to understand how this works.

cast-prim

(cast-prim accessor v)

Casts value v into the appropriate primitive number determined by the data accessor. Mostly useful for satisfying the compiler complaints in macros.

column?

(column? a)

Checks whether matrix a is laid column by column.

contiguous?

(contiguous? x)

Checks whether vector space x is ‘dense’, without gaps and strides.

count-entries

(count-entries accessor data)

Counts the number of entries in data according to the data accessor’s way of counting.

create-data-source

(create-data-source da-provider n)

Creates a memory block that can hold n entries according to data accessor’s way of counting.

data-accessor

(data-accessor provider)

Returns provider ’s data accessor.

entry-type

(entry-type accessor)

Returns the type of entries that this data accessor manages (double, float, etc.).

entry-width

(entry-width accessor)

Returns the width in bytes of entries that this data accessor manages (8 for double, etc.).

initialize

(initialize da-provider buf v)(initialize da-provider buf)

Initializes the buffer with the provied value, or zero.

offset

(offset x)

Returns offset in the underlying memory block that x actually controls. Since the transition to JavaCPP, this usually returns 0, and the pointer itself is responsible for handling offsets. Still used in OpenCL backend (based on JOCL), but a long term goal is to replace this with JavaCPP and deprecate this function.

row?

(row? a)

Checks whether matrix a is laid row by row.

stride

(stride x)

Returns stride between two adjacent group of elements in the underlying memory that holds x ’s data.