If you do either of the following then the call will return an expression sequence of containing three Matrices, and it will work for input A
a Matrix
.
with(LinearAlgebra):
P, L, U := LUDecomposition(A);
Or,
P, L, U := LinearAlgebra:-LUDecomposition(A);
But if you don't load the LinearAlgebra
package and you also don't use the long-form name of that package's export then you're simply making a function call to an undefined name.
And, if you are in fact accidentally simply calling the undefined name LUDecomposition
(because you have not used one of the mentioned methods for calling the package export of that name), then the result will be an unevaluated function call. And you cannot assign that single thing to three names on the left-hand-side of an assignment statement.
restart;
A := Matrix([[1,2],[3,5]]):
# Look, this next one does no computation.
# The return value is a single thing, an unevaluated
# function call.
LUDecomposition(A);
/[1 2]\
LUDecomposition|[ ]|
\[3 5]/
P, L, U := LUDecomposition(A);
Error, cannot split rhs for multiple assignment
But this would return the actual result,
LinearAlgebra:-LUDecomposition(A);
[1 0] [1 0] [1 2]
[ ], [ ], [ ]
[0 1] [3 1] [0 -1]
And so those three Matrices could be assigned to three names.
P, L, U := LinearAlgebra:-LUDecomposition(A);
[1 0] [1 0] [1 2]
P, L, U := [ ], [ ], [ ]
[0 1] [3 1] [0 -1]
Another way to do it is to first load the whole package, so that you can utilize the short-form command name,
with(LinearAlgebra):
LUDecomposition(A);
[1 0] [1 0] [1 2]
[ ], [ ], [ ]
[0 1] [3 1] [0 -1]
P, L, U := LUDecomposition(A);
[1 0] [1 0] [1 2]
P, L, U := [ ], [ ], [ ]
[0 1] [3 1] [0 -1]