How to setting for solving A x = b with A in R^{2 \times 3}, x in R^{3} and b in R^{2}?
It looks like you're asking for help with setting up a linear equation system in the form ( Ax = b ) using Julia, where ( A ) is a ( 2 \times 3 ) matrix, ( x ) is a ( 3 )-dimensional vector, and ( b ) is a ( 2 )-dimensional vector. Your code snippet is almost correct, but there are a couple of minor adjustments needed for clarity and correctness.
Here's a corrected version of your code:
## Packages
using Pardiso
using SparseArrays
gpmt = MKLPardisoSolver() # or gpmt = PardisoSolver()
## Data
A = [1 1 1; 2 4 2.0] # Define the matrix A
Acsr = sparse(A)
b = [35; 94.0] # Define the vector b
## Solving...
set_msglvl!(gpmt, 1)
xsol = solve(gpmt, Acsr , b)
The above gives me that
=== PARDISO is running in In-Core mode, because iparam(60)=0 ===
...
2-element Vector{Float64}:
23.0
12.0
But the result has only 2 elements. And i want 3 elements. If i write the code of
## Solving...
xs = zeros(3,1);
solve!(gpmt, xs, Acsr , b)
It gives me errors of
ERROR: DimensionMismatch: solution has (3, 1), RHS has size as (2,).
Although, i know reason from the dims of A{2,3} * x{3,1} = b{2,1}. And I should write code of
## Packages
using Pardiso
using SparseArrays
gpmt = MKLPardisoSolver() # or gpmt = PardisoSolver()
## Data
A = [1 1 1; 2 4 2.0] # Define the matrix A
Acsr = sparse(A'*A)
b = [35; 94.0] # Define the vector b
brhs = reshape(A'*b,3,1)
## Solving...
set_msglvl!(gpmt, 1)
xs = zeros(3,1);
solve!(gpmt, xs, Acsr , brhs)
So that, i want ask a question of Ax = b with A in ( R^{m \times n } ), x in R^{n} and b in R^{m} satisfying m < n. Hence, how to setting for solving this type of A x = b? And i translate Ax = b into A'*A x = A'*b, then solving it by Pardiso?
Sincerely, Aijunly, Jun Wang.
Pardiso only works for square systems. In your case what is happening is that it is actually solving the square system containing only first m columns.
Maybe we should update this so that it returns an error when trying to solve a non-square system.
yes, thanks.