Skip to content

Conversation

@gingerBill
Copy link
Member

@gingerBill gingerBill commented Oct 25, 2021

New type: matrix[R, C]T

Supports:

  • multiplication a * b
    • multiplication between matrices and arrays
    • matrix[A, B]T * matrix[B, C]T == matrix[A, C]T
    • matrix[N, M]T * [M]T== matrix[N, 1]T or [N]T
    • [N]T * matrix[N, M]T == matrix[1, M]T or [M]T
  • component-wise operations (if the element type supports it)
    • +, -, &, |, ~, &~, <<, >>
    • No support for: /, %, %%
  • matrix indexing: m[i, j]
    • Mirrors other type usages: type on the left, usage on the right
  • column-major array indexing m[j][i] == m[i, j]
  • Element types of integers, floats, complex numbers
    • No support for booleans, quaternions, nor any compound type
  • Compound literals, written row-major (to aid reading/writing) but stored column-major (performance):
m := matrix[2, 4]f32{
	1, 3, 5, 7, 
	2, 4, 6, 8,
}

Internal layout:

  • Column-major layout: matrix[R, C]T == [C][R]T
  • High alignment properties to allow for (SIMD) vectorization
  • Zero padding (alignment rules compensation for this)
    • Compromise of third-party libraries over performance benefits
  • Limited to a maximum of 16 elements (rows*columns), and a minimum of 1 element

Built-in Procedures (compiler-level)

  • tranpose(m)
  • outer_product(a, b)
  • hadamard_product(m)
  • matrix_flatten(m) (converts matrix into a flattened array (array of columns)
  • conj(m)

Built-in Procedures (library-level) (for square matrices)

  • determinant(m)
  • adjugate(m)
  • inverse(m)
  • inverse_transpose(m)
  • hermitian_adjoint(m)
  • matrix_trace(m)
  • matrix_minor(m)

@gingerBill gingerBill merged commit c4d2aae into master Oct 26, 2021
@gingerBill gingerBill deleted the new-matrix-type branch October 26, 2021 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant