Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Array slicing with MKL

Dylan_B_
Beginner
671 Views

Hi there,

I am currently working on a two-dimensional ADI Crank-Nicolson algorithm using the pardiso and cspblas packages. In order to use the Alternating-Direction-Implicit (ADI) method, I need to solve a linear system of equations Ax = By, where x and y are single columns and single rows from a 2D matrix. However I am having difficulty thinking of a way to extract singular rows and columns from a matrix.

Is there a fast way I can slice an array using the MKL package such that I do not have to iterate over my array every step?

In other languages this can be done by indexing in such a way   Ax[1,:] =  By[1,:]    for example.

 

Thanks,

Dylan

0 Kudos
3 Replies
Ying_H_Intel
Employee
671 Views

Hi Dylan,

You mentioned using the pardiso and cspblas packages. So can I suppose the loop and  extract singular rows and columns from a matrix are needed only in phase 3 steps. right?

and X and Y single columns and single rows from a 2D matrix. can you name  row or column?

I guess, it may be column.  then it should be ok  for call pardiso and cspblas without exacting.

As Pardiso support multiply right hand.  So you can call one blas function to compute B*Y=> Z as  multiply right hand (each column is a zi ) .  then you can get  all of xi at pardiso phase 3 once.   Thus no iteration are needed.

phase – integer, execution control. There are three major phases in the solving
process and one service phase
• Phase 1: Fill-in reduction analysis and symbolic factorization

pardiso()
• Phase 2: Numerical factorization

pardiso()
• Phase 3: Forward and Backward solve including iterative refinements
• Release Memory (phase ≤ 0).

If either xi and yi are row, you may reorig the AX=YB etc and using multiply right -hand support  to get what you wanted.

Best Regards,

Ying

 

0 Kudos
Dylan_B_
Beginner
671 Views

Hi Ying,

Thanks for the response. 

Can I use cblas to perform matrix-vector multiplication with multiple vectors at once?

For example A*Xi = Bi, where A,X and B are NxN matrices, and Bi is the ith column of B.

Thanks,

Dylan

0 Kudos
Ying_H_Intel
Employee
671 Views

Hi Dylan, 

If i understand correctly, yes, cblas_dgemm perform matrix -matrix multiplication, that equal  matrix-vector multiplication with multiply vectors at once.

for example,  for (i loop) Ci = A*Bi

for (i = 0; i < N; i++) {
        cblas_dgemv(CblasRowMajor,CblasNoTrans,N,N,alpha,a,N,&b,N,beta,&c,N);
 
=  
C=A*B

.  cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,     m, n, k, alpha, A, k, B, n, beta, C, n);

Best Regards,

Ying 

 

 

0 Kudos
Reply