5 #include
"/usr/local/include/gsl/gsl_sys.h"
7 %include
"/usr/local/include/gsl/gsl_sys.h"
9 %typemap
(in
) double
* (double dvalue
) {
12 croak
("Math::GSL::Sort : $input is not a reference!\n");
14 tempsv
= SvRV
($input
);
15 if
((!SvNOK
(tempsv
)) && (!SvIOK(tempsv))) {
16 croak
("Math::GSL::Sort : $input is not a reference to number!\n");
18 dvalue
= SvNV
(tempsv
);
21 %typemap
(argout
) double
* {
23 tempsv
= SvRV
($input
);
24 sv_setnv
(tempsv
, *$
1);
27 %typemap
(in
) gsl_complex const
[] {
33 SV
**elem
, **helem
, **real
, **imag
;
38 printf
("gsl_complex typemap\n");
40 croak
("Math::GSL : $input is not a reference!");
41 if
(SvTYPE
(SvRV
($input
)) != SVt_PVAV
)
42 croak
("Math::GSL : $input is not an array ref!");
44 z
= gsl_complex_rect
(0,0);
45 tempav
= (AV
*)SvRV
($input
);
47 $
1 = (gsl_complex
*) malloc
((len
+1)*sizeof
(gsl_complex
));
48 for
(i
= 0; i
<= len
; i
++) {
49 elem
= av_fetch
(tempav
, i
, 0);
51 hash
= (HV
*) SvRV
(*elem
);
52 helem
= hv_fetch
(hash
, "dat", 3, 0);
53 magic
= mg_get
(*helem
);
55 croak
("FETCH magic failed!\n");
57 printf
("magic = %d\n", magic
);
59 croak
("Structure does not contain 'dat' element\n");
60 printf
("helem is:\n");
63 svtmp
= (SV
*)SvRV
(*helem
);
66 printf
("re z = %f\n", GSL_REAL
(z
) );
67 printf
("im z = %f\n", GSL_IMAG
(z
) );
72 #include
"/usr/local/include/gsl/gsl_nan.h"
73 #include
"/usr/local/include/gsl/gsl_poly.h"
74 #include
"/usr/local/include/gsl/gsl_complex.h"
75 #include
"/usr/local/include/gsl/gsl_complex_math.h"
78 %include
"/usr/local/include/gsl/gsl_nan.h"
79 %include
"/usr/local/include/gsl/gsl_poly.h"
80 %include
"/usr/local/include/gsl/gsl_complex.h"
81 %include
"/usr/local/include/gsl/gsl_complex_math.h"
89 gsl_complex_poly_complex_eval
93 gsl_poly_solve_quadratic
94 gsl_poly_complex_solve_quadratic
96 gsl_poly_complex_solve_cubic
97 gsl_poly_complex_workspace_alloc
98 gsl_poly_complex_workspace_free
99 gsl_poly_complex_solve
100 $GSL_POSZERO $GSL_NEGZERO $GSL_NAN
102 our $GSL_NAN
= q
{nan
};
103 #our $GSL_POSZERO
= 0.0;
104 #our $GSL_NEGZERO
= -1*0.0;
106 %EXPORT_TAGS
= ( all
=> [ @EXPORT_OK
] );
112 Math
::GSL
::Poly
- Functions for evaluating and solving polynomials
116 use Math
::GSL
::Poly qw
/:all
/;
120 Here is a list of all the functions included in this module
:
124 gsl_poly_complex_eval
126 gsl_complex_poly_complex_eval
134 gsl_poly_solve_quadratic
136 gsl_poly_complex_solve_quadratic
138 gsl_poly_solve_cubic
($a
, $b
, $c
, \$x0
, \$x1
, \$x2
) - find the real roots of the cubic equation x
**3+$a
*x
**2+$b
*x
+$c
, return the number of real root
(either one or three
) and the real roots are returned bye $x0
, $x1 and $x2 which are deferenced.
140 gsl_poly_complex_solve_cubic
142 gsl_poly_complex_workspace_alloc
144 gsl_poly_complex_workspace_free
146 gsl_poly_complex_solve
148 For more informations on the functions
, we refer you to the GSL offcial documentation
: http
://www.gnu.org
/software
/gsl
/manual
/html_node
/
149 Tip
: search on google
: site
:http
://www.gnu.org
/software
/gsl
/manual
/html_node
/ name_of_the_function_you_want
153 use Math
::GSL
::Poly qw
/:all
/;
154 my
($a
,$b
,$c
) = (1,6,9);
155 my
($x0
, $x1
) = (0,0);
156 my $num_roots
= gsl_poly_solve_quadratic
( $a
, $b
, $c
, \$x0
, \$x1
);
157 print
"${a}*x**2 + ${b}*x + $c contains $num_roots roots which are $x0 and $x1. \n";
162 Jonathan Leto
<jonathan@leto.net
> and Thierry Moisan
<thierry.moisan@gmail.com
>
164 =head1 COPYRIGHT
AND LICENSE
166 Copyright
(C
) 2008 Jonathan Leto and Thierry Moisan
168 This program is free software
; you can redistribute it and
/or modify it
169 under the same terms as Perl itself.