Skip to content

Commit

Permalink
X * X^T and X * A * X^T support
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Stukalov authored and alyst committed Sep 17, 2024
1 parent 2002b71 commit 5326777
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,62 @@ function sp2md!(transA::Char, alpha::T, A::AbstractSparseMatrix{T}, descrA::matr
return C
end

# C := A * op(A), or
# C := op(A) * A, where C is sparse
# note: only the upper triangular part of C is computed
function syrk(transA::Char, A::AbstractSparseMatrix{T}) where T
check_trans(transA)
Cout = Ref{sparse_matrix_t}()
hA = MKLSparseMatrix(A)
res = mkl_call(Val{:mkl_sparse_syrkI}(), typeof(A),
transA, hA, Cout)
destroy(hA)
check_status(res)
return MKLSparseMatrix(Cout[])
end

# C := A * op(A), or
# C := op(A) * A, where C is dense
# note: only the upper triangular part of C is computed
function syrkd!(transA::Char, alpha::T, A::AbstractSparseMatrix{T}, beta::T,
C::StridedMatrix{T};
dense_layout::sparse_layout_t = SPARSE_LAYOUT_COLUMN_MAJOR
) where T
check_trans(transA)
check_mat_op_sizes(C, A, transA, A, transA == 'N' ? 'T' : 'N'; dense_layout)
ldC = stride(C, 2)
hA = MKLSparseMatrix(A)
res = mkl_call(Val{:mkl_sparse_T_syrkdI}(), typeof(A),
transA, hA, alpha, beta, C, dense_layout, ldC)
destroy(hA)
check_status(res)
return C
end

# C := alpha * op(A) * B * A + beta * C, or
# C := alpha * A * B * op(A) + beta * C, where C is dense
# note: only the upper triangular part of C is computed
function syprd!(transA::Char, alpha::T, A::AbstractSparseMatrix{T},
B::StridedMatrix{T}, beta::T, C::StridedMatrix{T};
dense_layout_B::sparse_layout_t = SPARSE_LAYOUT_COLUMN_MAJOR,
dense_layout_C::sparse_layout_t = SPARSE_LAYOUT_COLUMN_MAJOR
) where T
check_trans(transA)
# FIXME dense_layout_B not used
check_mat_op_sizes(C, A, transA, B, 'N';
check_result_columns = false, dense_layout = dense_layout_C)
check_mat_op_sizes(C, B, 'N', A, transA == 'N' ? 'T' : 'N';
check_result_rows = false, dense_layout = dense_layout_C)
ldB = stride(B, 2)
ldC = stride(C, 2)
hA = MKLSparseMatrix(A)
res = mkl_call(Val{:mkl_sparse_T_syprdI}(), typeof(A),
transA, hA, B, dense_layout_B, ldB,
alpha, beta, C, dense_layout_C, ldC)
destroy(hA)
check_status(res)
return C
end

# find y: op(A) * y = alpha * x
function trsv!(transA::Char, alpha::T, A::AbstractSparseMatrix{T}, descr::matrix_descr,
Expand Down

0 comments on commit 5326777

Please sign in to comment.