Here's an example of a function in Swift that provides a wrapper around cblas_sgemm
and handles transposing the input matrices if necessary:
main.swift950 chars20 lines
The function takes two input matrices matrixA
and matrixB
, along with the transpose flags for each matrix. The last four parameters represent the dimensions of the two matrices.
The function then performs some dimension checks to ensure that the input matrices are compatible for multiplication in their given orientation. If transpose is necessary, the function maps the dimensions accordingly.
Finally, the function calls cblas_sgemm
with the appropriate arguments and returns the resulting matrix as a flat array.
gistlibby LogSnag