Contents

la_matrix_from_float_buffer(_:_:_:_:_:_:)

Declaration

func la_matrix_from_float_buffer(_ buffer: UnsafePointer<Float>, _ matrix_rows: la_count_t, _ matrix_cols: la_count_t, _ matrix_row_stride: la_count_t, _ matrix_hint: la_hint_t, _ attributes: la_attribute_t) -> la_object_t

Parameters

  • buffer:

    Pointer to float data providing the elements of the matrix.

  • matrix_rows:

    The number of rows in the matrix.

  • matrix_cols:

    The number of columns in the matrix.

  • matrix_row_stride:

    The offset in the buffer (measured in floats) between corresponding elements in consecutive rows of the matrix. Must be positive.

  • matrix_hint:

    Flags describing special matrix structures.

  • attributes:

    Attributes to attach to the new la_object_t object. Pass LA_DEFAULT_ATTRIBUTES to create a normal object.

Return Value

A new la_object_t object representing the matrix.

Discussion

Create a matrix using data from a buffer of floats. Ownership of the buffer remains in control of the caller.

This function creates an object representing a matrix whose entries are copied out of the supplied buffer of floats. Negative or zero strides are not supported by this function (but note that you can reverse the rows or columns using the la_matrix_slice function defined below).

This routine assumes that the elements of the matrix are stored in the buffer in row-major order. If you need to work with data that is in column-major order, you can do that as follows:

  1. Use this routine to create a matrix object, but pass the number of columns in your matrix for the matrix_rows parameter and vice-versa. For the matrix_row_stride parameter, pass the column stride of your matrix.

  2. Make a new matrix transpose object from the object created in step 1. The resulting object represents the matrix that you want to work with.

See Also

Functions