Below is a possible implementation of a sgemm function that wraps cblas_sgemm:
main.swift875 chars23 linesThis function takes in two matrices a and b, and returns their matrix product c such that c = alpha * op(a) · op(b) + beta * c, where op(a) and op(b) are a and b if their corresponding transpose flags are false, and their transposes otherwise.
The transpose flags transposea and transposeb indicate whether the matrices a and b should be transposed before multiplication. The scalars alpha and beta are used to scale the matrices, with beta=0 corresponding to an overwrite of c.
The function performs some dimension checks to ensure that the matrix multiplication is valid, and uses the Accelerate framework's cblas_sgemm function to perform the actual computation. Note that the matrix dimensions and strides are interpreted assuming a row-major memory layout.
gistlibby LogSnag