Cleanup Deriv for merge.
[Math-GSL.git] / BLAS.i
blob2dbf48eb8820bcf1194cd1aedcd6fb7b6b7efe88
1 %module "Math::GSL::BLAS"
3 %include "typemaps.i"
4 %include "gsl_typemaps.i"
6 %apply float *OUTPUT { float *result };
7 %apply double *OUTPUT { double *result };
8 %apply double *OUTPUT { double c[], double s[] };
12 #include "gsl/gsl_blas.h"
13 #include "gsl/gsl_blas_types.h"
16 %include "gsl/gsl_blas.h"
17 %include "gsl/gsl_blas_types.h"
19 %perlcode %{
21 @EXPORT_OK_level1 = qw/
22 gsl_blas_sdsdot gsl_blas_dsdot gsl_blas_sdot gsl_blas_ddot
23 gsl_blas_cdotu gsl_blas_cdotc gsl_blas_zdotu gsl_blas_zdotc
24 gsl_blas_snrm2 gsl_blas_sasum gsl_blas_dnrm2 gsl_blas_dasum
25 gsl_blas_scnrm2 gsl_blas_scasum gsl_blas_dznrm2 gsl_blas_dzasum
26 gsl_blas_isamax gsl_blas_idamax gsl_blas_icamax gsl_blas_izamax
27 gsl_blas_sswap gsl_blas_scopy gsl_blas_saxpy gsl_blas_dswap
28 gsl_blas_dcopy gsl_blas_daxpy gsl_blas_cswap gsl_blas_ccopy
29 gsl_blas_caxpy gsl_blas_zswap gsl_blas_zcopy gsl_blas_zaxpy
30 gsl_blas_srotg gsl_blas_srotmg gsl_blas_srot gsl_blas_srotm
31 gsl_blas_drotg gsl_blas_drotmg gsl_blas_drot gsl_blas_drotm
32 gsl_blas_sscal gsl_blas_dscal gsl_blas_cscal gsl_blas_zscal
33 gsl_blas_csscal gsl_blas_zdscal
35 @EXPORT_OK_level2 = qw/
36 gsl_blas_sgemv gsl_blas_strmv
37 gsl_blas_strsv gsl_blas_dgemv gsl_blas_dtrmv gsl_blas_dtrsv
38 gsl_blas_cgemv gsl_blas_ctrmv gsl_blas_ctrsv gsl_blas_zgemv
39 gsl_blas_ztrmv gsl_blas_ztrsv gsl_blas_ssymv gsl_blas_sger
40 gsl_blas_ssyr gsl_blas_ssyr2 gsl_blas_dsymv gsl_blas_dger
41 gsl_blas_dsyr gsl_blas_dsyr2 gsl_blas_chemv gsl_blas_cgeru
42 gsl_blas_cgerc gsl_blas_cher gsl_blas_cher2 gsl_blas_zhemv
43 gsl_blas_zgeru gsl_blas_zgerc gsl_blas_zher gsl_blas_zher2
46 @EXPORT_OK_level3 = qw/
47 gsl_blas_sgemm gsl_blas_ssymm gsl_blas_ssyrk gsl_blas_ssyr2k
48 gsl_blas_strmm gsl_blas_strsm gsl_blas_dgemm gsl_blas_dsymm
49 gsl_blas_dsyrk gsl_blas_dsyr2k gsl_blas_dtrmm gsl_blas_dtrsm
50 gsl_blas_cgemm gsl_blas_csymm gsl_blas_csyrk gsl_blas_csyr2k
51 gsl_blas_ctrmm gsl_blas_ctrsm gsl_blas_zgemm gsl_blas_zsymm
52 gsl_blas_zsyrk gsl_blas_zsyr2k gsl_blas_ztrmm gsl_blas_ztrsm
53 gsl_blas_chemm gsl_blas_cherk gsl_blas_cher2k gsl_blas_zhemm
54 gsl_blas_zherk gsl_blas_zher2k
56 @EXPORT_OK = (@EXPORT_OK_level1, @EXPORT_OK_level2, @EXPORT_OK_level3);
57 %EXPORT_TAGS = (
58 all => [ @EXPORT_OK ],
59 level1 => [ @EXPORT_OK_level1 ],
60 level2 => [ @EXPORT_OK_level2 ],
61 level3 => [ @EXPORT_OK_level3 ],
63 __END__
65 =head1 NAME
67 Math::GSL::BLAS - Basic Linear Algebra Subprograms
69 =head1 SYNOPSIS
71 use Math::GSL::QRNG qw/:all/;
73 =head1 DESCRIPTION
75 The functions of this module are divised into 3 levels:
77 =head2 Level 1 - Vector operations
79 =over 3
81 =item C<gsl_blas_sdsdot>
83 =item C<gsl_blas_dsdot>
85 =item C<gsl_blas_sdot>
87 =item C<gsl_blas_ddot($x, $y)> - This function computes the scalar product x^T y for the vectors $x and $y. The function returns two values, the first is 0 if the operation suceeded, 1 otherwise and the second value is the result of the computation.
89 =item C<gsl_blas_cdotu>
91 =item C<gsl_blas_cdotc>
93 =item C<gsl_blas_zdotu($x, $y, $dotu)> - This function computes the complex scalar product x^T y for the complex vectors $x and $y, returning the result in the complex number $dotu. The function returns 0 if the operation suceeded, 1 otherwise.
95 =item C<gsl_blas_zdotc($x, $y, $dotc)> - This function computes the complex conjugate scalar product x^H y for the complex vectors $x and $y, returning the result in the complex number $dotc. The function returns 0 if the operation suceeded, 1 otherwise.
97 =item C<gsl_blas_snrm2>
98 =item C<gsl_blas_sasum>
100 =item C<gsl_blas_dnrm2($x)> - This function computes the Euclidean norm ||x||_2 = \sqrt {\sum x_i^2} of the vector $x.
102 =item C<gsl_blas_dasum($x)> - This function computes the absolute sum \sum |x_i| of the elements of the vector $x.
104 =item C<gsl_blas_scnrm2>
106 =item C<gsl_blas_scasum>
108 =item C<gsl_blas_dznrm2($x)> - This function computes the Euclidean norm of the complex vector $x, ||x||_2 = \sqrt {\sum (\Re(x_i)^2 + \Im(x_i)^2)}.
110 =item C<gsl_blas_dzasum($x)> - This function computes the sum of the magnitudes of the real and imaginary parts of the complex vector $x, \sum |\Re(x_i)| + |\Im(x_i)|.
112 =item C<gsl_blas_isamax>
114 =item C<gsl_blas_idamax>
116 =item C<gsl_blas_icamax>
118 =item C<gsl_blas_izamax >
120 =item C<gsl_blas_sswap>
122 =item C<gsl_blas_scopy>
124 =item C<gsl_blas_saxpy>
126 =item C<gsl_blas_dswap($x, $y)> - This function exchanges the elements of the vectors $x and $y. The function returns 0 if the operation suceeded, 1 otherwise.
128 =item C<gsl_blas_dcopy($x, $y)> - This function copies the elements of the vector $x into the vector $y. The function returns 0 if the operation suceeded, 1 otherwise.
130 =item C<gsl_blas_daxpy($alpha, $x, $y)> - These functions compute the sum $y = $alpha * $x + $y for the vectors $x and $y.
132 =item C<gsl_blas_cswap>
134 =item C<gsl_blas_ccopy >
136 =item C<gsl_blas_caxpy>
138 =item C<gsl_blas_zswap>
140 =item C<gsl_blas_zcopy>
142 =item C<gsl_blas_zaxpy >
144 =item C<gsl_blas_srotg>
146 =item C<gsl_blas_srotmg>
148 =item C<gsl_blas_srot>
150 =item C<gsl_blas_srotm >
152 =item C<gsl_blas_drotg>
154 =item C<gsl_blas_drotmg>
156 =item C<gsl_blas_drot($x, $y, $c, $s)> - This function applies a Givens rotation (x', y') = (c x + s y, -s x + c y) to the vectors $x, $y.
158 =item C<gsl_blas_drotm >
160 =item C<gsl_blas_sscal>
162 =item C<gsl_blas_dscal($alpha, $x)> - This function rescales the vector $x by the multiplicative factor $alpha.
164 =item C<gsl_blas_cscal>
166 =item C<gsl_blas_zscal >
168 =item C<gsl_blas_csscal>
170 =item C<gsl_blas_zdscal>
172 =back
174 =head2 Level 2 - Matrix-vector operations
176 =over 3
178 =item C<gsl_blas_sgemv>
180 =item C<gsl_blas_strmv >
182 =item C<gsl_blas_strsv>
184 =item C<gsl_blas_dgemv($TransA, $alpha, $A, $x, $beta, $y)> - This function computes the matrix-vector product and sum y = \alpha op(A) x + \beta y, where op(A) = A, A^T, A^H for $TransA = $CblasNoTrans, $CblasTrans, $CblasConjTrans (constant values coming from the CBLAS module). $A is a matrix and $x and $y are vectors. The function returns 0 if the operation suceeded, 1 otherwise.
186 =item C<gsl_blas_dtrmv($Uplo, $TransA, $Diag, $A, $x)> - This function computes the matrix-vector product x = op(A) x for the triangular matrix $A, where op(A) = A, A^T, A^H for $TransA = $CblasNoTrans, $CblasTrans, $CblasConjTrans (constant values coming from the CBLAS module). When $Uplo is $CblasUpper then the upper triangle of $A is used, and when $Uplo is $CblasLower then the lower triangle of $A is used. If $Diag is $CblasNonUnit then the diagonal of the matrix is used, but if $Diag is $CblasUnit then the diagonal elements of the matrix $A are taken as unity and are not referenced. The function returns 0 if the operation suceeded, 1 otherwise.
188 =item C<gsl_blas_dtrsv($Uplo, $TransA, $Diag, $A, $x)> - This function computes inv(op(A)) x for the vector $x, where op(A) = A, A^T, A^H for $TransA = $CblasNoTrans, $CblasTrans, $CblasConjTrans (constant values coming from the CBLAS module). When $Uplo is $CblasUpper then the upper triangle of $A is used, and when $Uplo is $CblasLower then the lower triangle of $A is used. If $Diag is $CblasNonUnit then the diagonal of the matrix is used, but if $Diag is $CblasUnit then the diagonal elements of the matrix $A are taken as unity and are not referenced. The function returns 0 if the operation suceeded, 1 otherwise.
190 =item C<gsl_blas_cgemv >
192 =item C<gsl_blas_ctrmv>
194 =item C<gsl_blas_ctrsv>
196 =item C<gsl_blas_zgemv >
198 =item C<gsl_blas_ztrmv>
200 =item C<gsl_blas_ztrsv>
202 =item C<gsl_blas_ssymv>
204 =item C<gsl_blas_sger >
206 =item C<gsl_blas_ssyr>
208 =item C<gsl_blas_ssyr2>
210 =item C<gsl_blas_dsymv>
212 =item C<gsl_blas_dger($alpha, $x, $y, $A)> - This function computes the rank-1 update A = alpha x y^T + A of the matrix $A. $x and $y are vectors. The function returns 0 if the operation suceeded, 1 otherwise.
214 =item C<gsl_blas_dsyr($Uplo, $alpha, $x, $A)> - This function computes the symmetric rank-1 update A = \alpha x x^T + A of the symmetric matrix $A and the vector $x. Since the matrix $A is symmetric only its upper half or lower half need to be stored. When $Uplo is $CblasUpper then the upper triangle and diagonal of $A are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $A are used. The function returns 0 if the operation suceeded, 1 otherwise.
216 =item C<gsl_blas_dsyr2($Uplo, $alpha, $x, $y, $A)> - This function computes the symmetric rank-2 update A = \alpha x y^T + \alpha y x^T + A of the symmetric matrix $A, the vector $x and vector $y. Since the matrix $A is symmetric only its upper half or lower half need to be stored. When $Uplo is $CblasUpper then the upper triangle and diagonal of $A are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $A are used.
218 =item C<gsl_blas_chemv>
220 =item C<gsl_blas_cgeru >
222 =item C<gsl_blas_cgerc>
224 =item C<gsl_blas_cher>
226 =item C<gsl_blas_cher2>
228 =item C<gsl_blas_zhemv >
230 =item C<gsl_blas_zgeru($alpha, $x, $y, $A)> - This function computes the rank-1 update A = alpha x y^T + A of the complex matrix $A. $alpha is a complex number and $x and $y are complex vectors. The function returns 0 if the operation suceeded, 1 otherwise.
232 =item C<gsl_blas_zgerc>
234 =item C<gsl_blas_zher($Uplo, $alpha, $x, $A)> - This function computes the hermitian rank-1 update A = \alpha x x^H + A of the hermitian matrix $A and of the complex vector $x. Since the matrix $A is hermitian only its upper half or lower half need to be stored. When $Uplo is $CblasUpper then the upper triangle and diagonal of $A are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $A are used. The imaginary elements of the diagonal are automatically set to zero. The function returns 0 if the operation suceeded, 1 otherwise.
237 =item C<gsl_blas_zher2 >
239 =back
241 =head2 Level 3 - Matrix-matrix operations
243 =over 3
245 =item C<gsl_blas_sgemm>
247 =item C<gsl_blas_ssymm>
249 =item C<gsl_blas_ssyrk>
251 =item C<gsl_blas_ssyr2k >
253 =item C<gsl_blas_strmm>
255 =item C<gsl_blas_strsm>
257 =item C<gsl_blas_dgemm($TransA, $TransB, $alpha, $A, $B, $beta, $C)> - This function computes the matrix-matrix product and sum C = \alpha op(A) op(B) + \beta C where op(A) = A, A^T, A^H for $TransA = $CblasNoTrans, $CblasTrans, $CblasConjTrans and similarly for the parameter $TransB. The function returns 0 if the operation suceeded, 1 otherwise.
259 =item C<gsl_blas_dsymm($Side, $Uplo, $alpha, $A, $B, $beta, $C)> - This function computes the matrix-matrix product and sum C = \alpha A B + \beta C for $Side is $CblasLeft and C = \alpha B A + \beta C for $Side is $CblasRight, where the matrix $A is symmetric. When $Uplo is $CblasUpper then the upper triangle and diagonal of $A are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $A are used. The function returns 0 if the operation suceeded, 1 otherwise.
261 =item C<gsl_blas_dsyrk($Uplo, $Trans, $alpha, $A, $beta, $C)> - This function computes a rank-k update of the symmetric matrix $C, C = \alpha A A^T + \beta C when $Trans is $CblasNoTrans and C = \alpha A^T A + \beta C when $Trans is $CblasTrans. Since the matrix $C is symmetric only its upper half or lower half need to be stored. When $Uplo is $CblasUpper then the upper triangle and diagonal of $C are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $C are used. The function returns 0 if the operation suceeded, 1 otherwise.
263 =item C<gsl_blas_dsyr2k($Uplo, $Trans, $alpha, $A, $B, $beta, $C)> - This function computes a rank-2k update of the symmetric matrix $C, C = \alpha A B^T + \alpha B A^T + \beta C when $Trans is $CblasNoTrans and C = \alpha A^T B + \alpha B^T A + \beta C when $Trans is $CblasTrans. Since the matrix $C is symmetric only its upper half or lower half need to be stored. When $Uplo is $CblasUpper then the upper triangle and diagonal of $C are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $C are used. The function returns 0 if the operation suceeded, 1 otherwise.
265 =item C<gsl_blas_dtrmm($Side, $Uplo, $TransA, $Diag, $alpha, $A, $B)> - This function computes the matrix-matrix product B = \alpha op(A) B for $Side is $CblasLeft and B = \alpha B op(A) for $Side is $CblasRight. The matrix $A is triangular and op(A) = A, A^T, A^H for $TransA = $CblasNoTrans, $CblasTrans, $CblasConjTrans. When $Uplo is $CblasUpper then the upper triangle of $A is used, and when $Uplo is $CblasLower then the lower triangle of $A is used. If $Diag is $CblasNonUnit then the diagonal of $A is used, but if $Diag is $CblasUnit then the diagonal elements of the matrix $A are taken as unity and are not referenced. The function returns 0 if the operation suceeded, 1 otherwise.
267 =item C<gsl_blas_dtrsm($Side, $Uplo, $TransA, $Diag, $alpha, $A, $B)> - This function computes the inverse-matrix matrix product B = \alpha op(inv(A))B for $Side is $CblasLeft and B = \alpha B op(inv(A)) for $Side is $CblasRight. The matrix $A is triangular and op(A) = A, A^T, A^H for $TransA = $CblasNoTrans, $CblasTrans, $CblasConjTrans. When $Uplo is $CblasUpper then the upper triangle of $A is used, and when $Uplo is $CblasLower then the lower triangle of $A is used. If $Diag is $CblasNonUnit then the diagonal of $A is used, but if $Diag is $CblasUnit then the diagonal elements of the matrix $A are taken as unity and are not referenced. The function returns 0 if the operation suceeded, 1 otherwise.
269 =item C<gsl_blas_cgemm>
271 =item C<gsl_blas_csymm>
273 =item C<gsl_blas_csyrk>
275 =item C<gsl_blas_csyr2k >
277 =item C<gsl_blas_ctrmm>
279 =item C<gsl_blas_ctrsm>
281 =item C<gsl_blas_zgemm($TransA, $TransB, $alpha, $A, $B, $beta, $C)> - This function computes the matrix-matrix product and sum C = \alpha op(A) op(B) + \beta C where op(A) = A, A^T, A^H for $TransA = $CblasNoTrans, $CblasTrans, $CblasConjTrans and similarly for the parameter $TransB. The function returns 0 if the operation suceeded, 1 otherwise. $A, $B and $C are complex matrices
283 =item C<gsl_blas_zsymm($Side, $Uplo, $alpha, $A, $B, $beta, $C)> - This function computes the matrix-matrix product and sum C = \alpha A B + \beta C for $Side is $CblasLeft and C = \alpha B A + \beta C for $Side is $CblasRight, where the matrix $A is symmetric. When $Uplo is $CblasUpper then the upper triangle and diagonal of $A are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $A are used. $A, $B and $C are complex matrices. The function returns 0 if the operation suceeded, 1 otherwise.
285 =item C<gsl_blas_zsyrk($Uplo, $Trans, $alpha, $A, $beta, $C)> - This function computes a rank-k update of the symmetric complex matrix $C, C = \alpha A A^T + \beta C when $Trans is $CblasNoTrans and C = \alpha A^T A + \beta C when $Trans is $CblasTrans. Since the matrix $C is symmetric only its upper half or lower half need to be stored. When $Uplo is $CblasUpper then the upper triangle and diagonal of $C are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $C are used. The function returns 0 if the operation suceeded, 1 otherwise.
287 =item C<gsl_blas_zsyr2k($Uplo, $Trans, $alpha, $A, $B, $beta, $C)> - This function computes a rank-2k update of the symmetric matrix $C, C = \alpha A B^T + \alpha B A^T + \beta C when $Trans is $CblasNoTrans and C = \alpha A^T B + \alpha B^T A + \beta C when $Trans is $CblasTrans. Since the matrix $C is symmetric only its upper half or lower half need to be stored. When $Uplo is $CblasUpper then the upper triangle and diagonal of $C are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $C are used. The function returns 0 if the operation suceeded, 1 otherwise. $A, $B and $C are complex matrices and $beta is a complex number.
289 =item C<gsl_blas_ztrmm($Side, $Uplo, $TransA, $Diag, $alpha, $A, $B)> - This function computes the matrix-matrix product B = \alpha op(A) B for $Side is $CblasLeft and B = \alpha B op(A) for $Side is $CblasRight. The matrix $A is triangular and op(A) = A, A^T, A^H for $TransA = $CblasNoTrans, $CblasTrans, $CblasConjTrans. When $Uplo is $CblasUpper then the upper triangle of $A is used, and when $Uplo is $CblasLower then the lower triangle of $A is used. If $Diag is $CblasNonUnit then the diagonal of $A is used, but if $Diag is $CblasUnit then the diagonal elements of the matrix $A are taken as unity and are not referenced. The function returns 0 if the operation suceeded, 1 otherwise. $A and $B are complex matrices and $alpha is a complex number.
291 =item C<gsl_blas_ztrsm($Side, $Uplo, $TransA, $Diag, $alpha, $A, $B)> - This function computes the inverse-matrix matrix product B = \alpha op(inv(A))B for $Side is $CblasLeft and B = \alpha B op(inv(A)) for $Side is $CblasRight. The matrix $A is triangular and op(A) = A, A^T, A^H for $TransA = $CblasNoTrans, $CblasTrans, $CblasConjTrans. When $Uplo is $CblasUpper then the upper triangle of $A is used, and when $Uplo is $CblasLower then the lower triangle of $A is used. If $Diag is $CblasNonUnit then the diagonal of $A is used, but if $Diag is $CblasUnit then the diagonal elements of the matrix $A are taken as unity and are not referenced. The function returns 0 if the operation suceeded, 1 otherwise. $A and $B are complex matrices and $alpha is a complex number.
293 =item C<gsl_blas_chemm>
295 =item C<gsl_blas_cherk>
297 =item C<gsl_blas_cher2k>
299 =item C<gsl_blas_zhemm($Side, $Uplo, $alpha, $A, $B, $beta, $C)> - This function computes the matrix-matrix product and sum C = \alpha A B + \beta C for $Side is $CblasLeft and C = \alpha B A + \beta C for $Side is $CblasRight, where the matrix $A is hermitian. When Uplo is CblasUpper then the upper triangle and diagonal of A are used, and when Uplo is CblasLower then the lower triangle and diagonal of A are used. The imaginary elements of the diagonal are automatically set to zero.
301 =item C<gsl_blas_zherk($Uplo, $Trans, $alpha, $A, $beta, $C)> - This function computes a rank-k update of the hermitian matrix $C, C = \alpha A A^H + \beta C when $Trans is $CblasNoTrans and C = \alpha A^H A + \beta C when $Trans is $CblasTrans. Since the matrix $C is hermitian only its upper half or lower half need to be stored. When $Uplo is $CblasUpper then the upper triangle and diagonal of $C are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $C are used. The imaginary elements of the diagonal are automatically set to zero. The function returns 0 if the operation suceeded, 1 otherwise. $A, $B and $C are complex matrices and $alpha and $beta are complex numbers.
303 =item C<gsl_blas_zher2k($Uplo, $Trans, $alpha, $A, $B, $beta, $C)> - This function computes a rank-2k update of the hermitian matrix $C, C = \alpha A B^H + \alpha^* B A^H + \beta C when $Trans is $CblasNoTrans and C = \alpha A^H B + \alpha^* B^H A + \beta C when $Trans is $CblasConjTrans. Since the matrix $C is hermitian only its upper half or lower half need to be stored. When $Uplo is $CblasUpper then the upper triangle and diagonal of $C are used, and when $Uplo is $CblasLower then the lower triangle and diagonal of $C are used. The imaginary elements of the diagonal are automatically set to zero. The function returns 0 if the operation suceeded, 1 otherwise.
305 =back
307 You have to add the functions you want to use inside the qw /put_funtion_here /.
308 You can also write use Math::GSL::PowInt qw/:all/ to use all avaible functions of the module.
309 Other tags are also avaible, here is a complete list of all tags for this module :
311 =over 3
313 =item C<level1>
315 =item C<level2>
317 =item C<level3>
319 =back
321 For more informations on the functions, we refer you to the GSL offcial documentation: L<http://www.gnu.org/software/gsl/manual/html_node/>
323 Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want
326 =head1 EXAMPLES
328 =head1 AUTHORS
330 Jonathan Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
332 =head1 COPYRIGHT AND LICENSE
334 Copyright (C) 2008 Jonathan Leto and Thierry Moisan
336 This program is free software; you can redistribute it and/or modify it
337 under the same terms as Perl itself.
339 =cut