Skip to content
ForCADDocumentation

kron Interface

public interface kron

Compute supported Kronecker products without calling matmul.

Overloads cover vector-vector, vector-matrix, and a three-factor tensor product. Their flattening order is consistent with ForCAD control nets.


Module Procedures

private pure function kron_t1_t1(u, v) result(w)

Form the Kronecker product of two vectors.

The result is ordered in blocks of v: w((i-1)*size(v)+j)=u(i)*v(j).

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: u(:)

Left vector.

real(kind=rk), intent(in), contiguous :: v(:)

Right vector, varying fastest in the result.

Return Value real(kind=rk), (size(u)*size(v))

Kronecker product of length size(u)*size(v).

private pure function kron_t1_t2(u, A) result(B)

Form the Kronecker product of a vector and a matrix.

Every row of A is scaled by each entry of u; the matrix columns are retained and the A row index varies fastest inside each u block.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: u(:)

Left vector of length m.

real(kind=rk), intent(in), contiguous :: A(:,:)

Right matrix of shape [r,c].

Return Value real(kind=rk), (size(u)*size(A,1),size(A,2))

Kronecker product of shape [m*r,c].

private pure function kron_t2_t2(A, B) result(C)

Matrix Kronecker product, with the right factor varying fastest.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: A(:,:)
real(kind=rk), intent(in) :: B(:,:)

Return Value real(kind=rk), (size(A,1)*size(B,1),size(A,2)*size(B,2))

private pure function kron3(u, v, w) result(out)

Form a flattened three-vector tensor product.

w varies fastest, followed by v and then u, matching the ordering used by the ForCAD tensor-product geometry modules.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), contiguous :: u(:)

First tensor factor, varying slowest.

real(kind=rk), intent(in), contiguous :: v(:)

Second tensor factor.

real(kind=rk), intent(in), contiguous :: w(:)

Third tensor factor, varying fastest.

Return Value real(kind=rk), (size(u)*size(v)*size(w))

Flattened product u(i)*v(j)*w(k).