LINALG.pm (PDL-2.074) | : | LINALG.pm (PDL-2.075) | ||
---|---|---|---|---|
skipping to change at line 17 | skipping to change at line 17 | |||
our %EXPORT_TAGS = (Func=>\@EXPORT_OK); | our %EXPORT_TAGS = (Func=>\@EXPORT_OK); | |||
use PDL::Core; | use PDL::Core; | |||
use PDL::Exporter; | use PDL::Exporter; | |||
use DynaLoader; | use DynaLoader; | |||
our @ISA = ( 'PDL::Exporter','DynaLoader' ); | our @ISA = ( 'PDL::Exporter','DynaLoader' ); | |||
push @PDL::Core::PP, __PACKAGE__; | push @PDL::Core::PP, __PACKAGE__; | |||
bootstrap PDL::GSL::LINALG ; | bootstrap PDL::GSL::LINALG ; | |||
#line 5 "gsl_linalg.pd" | #line 4 "gsl_linalg.pd" | |||
use strict; | use strict; | |||
use warnings; | use warnings; | |||
=head1 NAME | =head1 NAME | |||
PDL::GSL::LINALG - PDL interface to linear algebra routines in GSL | PDL::GSL::LINALG - PDL interface to linear algebra routines in GSL | |||
=head1 SYNOPSIS | =head1 SYNOPSIS | |||
use PDL::LiteF; | use PDL::LiteF; | |||
use PDL::MatrixOps; # for 'x' | use PDL::MatrixOps; # for 'x' | |||
use PDL::GSL::LINALG; | use PDL::GSL::LINALG; | |||
my $A = pdl [ | my $A = pdl [ | |||
[0.18, 0.60, 0.57, 0.96], | [0.18, 0.60, 0.57, 0.96], | |||
[0.41, 0.24, 0.99, 0.58], | [0.41, 0.24, 0.99, 0.58], | |||
[0.14, 0.30, 0.97, 0.66], | [0.14, 0.30, 0.97, 0.66], | |||
[0.51, 0.13, 0.19, 0.85], | [0.51, 0.13, 0.19, 0.85], | |||
]; | ]; | |||
my $B = sequence(2,4); # column vectors | my $B = sequence(2,4); # column vectors | |||
LU_decomp(my $lu=$A->copy, my $p=null, my $signum=null); | LU_decomp(my $lu=$A->copy, my $p=null, my $signum=null); | |||
# transpose so first dim means is vector, higher dims thread | # transpose so first dim means is vector, higher dims broadcast | |||
LU_solve($lu, $p, $B->transpose, my $x=null); | LU_solve($lu, $p, $B->transpose, my $x=null); | |||
$x = $x->inplace->transpose; # now can be matrix-multiplied | $x = $x->inplace->transpose; # now can be matrix-multiplied | |||
=head1 DESCRIPTION | =head1 DESCRIPTION | |||
This is an interface to the linear algebra package present in the | This is an interface to the linear algebra package present in the | |||
GNU Scientific Library. Functions are named as in GSL, but with the | GNU Scientific Library. Functions are named as in GSL, but with the | |||
initial C<gsl_linalg_> removed. They are provided in both real and | initial C<gsl_linalg_> removed. They are provided in both real and | |||
complex double precision. | complex double precision. | |||
Currently only LU decomposition interfaces here. Pull requests welcome! | Currently only LU decomposition interfaces here. Pull requests welcome! | |||
#line 58 "LINALG.pm" | #line 59 "LINALG.pm" | |||
=head1 FUNCTIONS | =head1 FUNCTIONS | |||
=cut | =cut | |||
#line 1059 "../../../blib/lib/PDL/PP.pm" | #line 1058 "../../../blib/lib/PDL/PP.pm" | |||
=head2 LU_decomp | =head2 LU_decomp | |||
=for sig | =for sig | |||
Signature: ([io,phys]A(n,m); indx [o,phys]ipiv(p); int [o,phys]signum()) | Signature: ([io,phys]A(n,m); indx [o,phys]ipiv(p); int [o,phys]signum()) | |||
=for ref | =for ref | |||
LU decomposition of the given (real or complex) matrix. | LU decomposition of the given (real or complex) matrix. | |||
=for bad | =for bad | |||
LU_decomp ignores the bad-value flag of the input ndarrays. | LU_decomp ignores the bad-value flag of the input ndarrays. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 94 "LINALG.pm" | #line 96 "LINALG.pm" | |||
#line 1060 "../../../blib/lib/PDL/PP.pm" | ||||
#line 1061 "../../../blib/lib/PDL/PP.pm" | ||||
*LU_decomp = \&PDL::LU_decomp; | *LU_decomp = \&PDL::LU_decomp; | |||
#line 100 "LINALG.pm" | #line 103 "LINALG.pm" | |||
#line 1059 "../../../blib/lib/PDL/PP.pm" | #line 1058 "../../../blib/lib/PDL/PP.pm" | |||
=head2 LU_solve | =head2 LU_solve | |||
=for sig | =for sig | |||
Signature: ([phys]LU(n,m); indx [phys]ipiv(p); [phys]B(n); [o,phys]x(n)) | Signature: ([phys]LU(n,m); indx [phys]ipiv(p); [phys]B(n); [o,phys]x(n)) | |||
=for ref | =for ref | |||
Solve C<A x = B> using the LU and permutation from L</LU_decomp>, real | Solve C<A x = B> using the LU and permutation from L</LU_decomp>, real | |||
or complex. | or complex. | |||
=for bad | =for bad | |||
LU_solve ignores the bad-value flag of the input ndarrays. | LU_solve ignores the bad-value flag of the input ndarrays. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 127 "LINALG.pm" | #line 131 "LINALG.pm" | |||
#line 1060 "../../../blib/lib/PDL/PP.pm" | ||||
#line 1061 "../../../blib/lib/PDL/PP.pm" | ||||
*LU_solve = \&PDL::LU_solve; | *LU_solve = \&PDL::LU_solve; | |||
#line 133 "LINALG.pm" | #line 138 "LINALG.pm" | |||
#line 1059 "../../../blib/lib/PDL/PP.pm" | #line 1058 "../../../blib/lib/PDL/PP.pm" | |||
=head2 LU_det | =head2 LU_det | |||
=for sig | =for sig | |||
Signature: ([phys]LU(n,m); int [phys]signum(); [o]det()) | Signature: ([phys]LU(n,m); int [phys]signum(); [o]det()) | |||
=for ref | =for ref | |||
Find the determinant from the LU decomp. | Find the determinant from the LU decomp. | |||
=for bad | =for bad | |||
LU_det ignores the bad-value flag of the input ndarrays. | LU_det ignores the bad-value flag of the input ndarrays. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 159 "LINALG.pm" | #line 165 "LINALG.pm" | |||
#line 1060 "../../../blib/lib/PDL/PP.pm" | ||||
#line 1061 "../../../blib/lib/PDL/PP.pm" | ||||
*LU_det = \&PDL::LU_det; | *LU_det = \&PDL::LU_det; | |||
#line 165 "LINALG.pm" | #line 172 "LINALG.pm" | |||
#line 1059 "../../../blib/lib/PDL/PP.pm" | #line 1058 "../../../blib/lib/PDL/PP.pm" | |||
=head2 solve_tridiag | =head2 solve_tridiag | |||
=for sig | =for sig | |||
Signature: ([phys]diag(n); [phys]superdiag(n); [phys]subdiag(n); [phys]B(n); [ o,phys]x(n)) | Signature: ([phys]diag(n); [phys]superdiag(n); [phys]subdiag(n); [phys]B(n); [ o,phys]x(n)) | |||
=for ref | =for ref | |||
Solve C<A x = B> where A is a tridiagonal system. Real only, because | Solve C<A x = B> where A is a tridiagonal system. Real only, because | |||
GSL does not have a complex function. | GSL does not have a complex function. | |||
=for bad | =for bad | |||
solve_tridiag ignores the bad-value flag of the input ndarrays. | solve_tridiag ignores the bad-value flag of the input ndarrays. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 192 "LINALG.pm" | #line 200 "LINALG.pm" | |||
#line 1060 "../../../blib/lib/PDL/PP.pm" | ||||
#line 1061 "../../../blib/lib/PDL/PP.pm" | ||||
*solve_tridiag = \&PDL::solve_tridiag; | *solve_tridiag = \&PDL::solve_tridiag; | |||
#line 198 "LINALG.pm" | #line 207 "LINALG.pm" | |||
#line 40 "gsl_linalg.pd" | ||||
#line 41 "gsl_linalg.pd" | ||||
=head1 SEE ALSO | =head1 SEE ALSO | |||
L<PDL> | L<PDL> | |||
The GSL documentation for linear algebra is online at | The GSL documentation for linear algebra is online at | |||
L<https://www.gnu.org/software/gsl/doc/html/linalg.html> | L<https://www.gnu.org/software/gsl/doc/html/linalg.html> | |||
=cut | =cut | |||
#line 213 "LINALG.pm" | #line 223 "LINALG.pm" | |||
# Exit with OK status | # Exit with OK status | |||
1; | 1; | |||
End of changes. 21 change blocks. | ||||
21 lines changed or deleted | 27 lines changed or added |