4 %typemap
(in
) double
* (double dvalue
) {
7 croak
("Math::GSL::Sort : $input is not a reference!\n");
10 if
((!SvNOK
(tempsv
)) && (!SvIOK(tempsv))) {
11 croak
("Math::GSL::Sort : $input is not a reference to number!\n");
13 dvalue
= SvNV
(tempsv
);
16 %typemap
(argout
) double
* {
18 tempsv
= SvRV
($input
);
19 sv_setnv
(tempsv
, *$
1);
22 %typemap
(in
) gsl_complex const
[] {
28 SV
**elem
, **helem
, **real
, **imag
;
33 printf
("gsl_complex typemap\n");
35 croak
("Math::GSL : $input is not a reference!");
36 if
(SvTYPE
(SvRV
($input
)) != SVt_PVAV
)
37 croak
("Math::GSL : $input is not an array ref!");
39 z
= gsl_complex_rect
(0,0);
40 tempav
= (AV
*)SvRV
($input
);
42 $
1 = (gsl_complex
*) malloc
((len
+1)*sizeof
(gsl_complex
));
43 for
(i
= 0; i
<= len
; i
++) {
44 elem
= av_fetch
(tempav
, i
, 0);
46 hash
= (HV
*) SvRV
(*elem
);
47 helem
= hv_fetch
(hash
, "dat", 3, 0);
48 magic
= mg_get
(*helem
);
50 croak
("FETCH magic failed!\n");
52 printf
("magic = %d\n", magic
);
54 croak
("Structure does not contain 'dat' element\n");
55 printf
("helem is:\n");
58 svtmp
= (SV
*)SvRV
(*helem
);
61 printf
("re z = %f\n", GSL_REAL
(z
) );
62 printf
("im z = %f\n", GSL_IMAG
(z
) );
68 #include
"/usr/local/include/gsl/gsl_nan.h"
69 #include
"/usr/local/include/gsl/gsl_poly.h"
70 #include
"/usr/local/include/gsl/gsl_complex.h"
71 #include
"/usr/local/include/gsl/gsl_complex_math.h"
74 %include
"/usr/local/include/gsl/gsl_nan.h"
75 %include
"/usr/local/include/gsl/gsl_poly.h"
76 %include
"/usr/local/include/gsl/gsl_complex.h"
77 %include
"/usr/local/include/gsl/gsl_complex_math.h"
85 gsl_complex_poly_complex_eval
89 gsl_poly_solve_quadratic
90 gsl_poly_complex_solve_quadratic
92 gsl_poly_complex_solve_cubic
93 gsl_poly_complex_workspace_alloc
94 gsl_poly_complex_workspace_free
95 gsl_poly_complex_solve
96 $GSL_POSZERO $GSL_NEGZERO $GSL_NAN
98 our $GSL_NAN
= q
{nan
};
99 #our $GSL_POSZERO
= 0.0;
100 #our $GSL_NEGZERO
= -1*0.0;
102 %EXPORT_TAGS
= ( all
=> [ @EXPORT_OK
] );
109 Functions for evaluating and solving polynomials
113 use Math
::GSL
::Poly qw
/:all
/;
117 Here is a list of all the functions included in this module
:
121 gsl_poly_complex_eval
123 gsl_complex_poly_complex_eval
131 gsl_poly_solve_quadratic
133 gsl_poly_complex_solve_quadratic
135 gsl_poly_solve_cubic
($a
, $b
, $c
, \$x0
, \$x1
, \$x2
) - find the real roots of the cubic equation x³
+$a
*x²
+$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.
137 gsl_poly_complex_solve_cubic
139 gsl_poly_complex_workspace_alloc
141 gsl_poly_complex_workspace_free
143 gsl_poly_complex_solve
145 For more informations on the functions
, we refer you to the GSL offcial documentation
: http
://www.gnu.org
/software
/gsl
/manual
/html_node
/
146 Tip
: search on google
: site
:http
://www.gnu.org
/software
/gsl
/manual
/html_node
/ name_of_the_function_you_want
150 use Math
::GSL
::Poly qw
/:all
/;
156 $num_roots
= gsl_poly_solve_quadratic
( $a
, $b
, $c
, \$x0
, \$x1
);
157 print
"x²+6x+9 contains $num_roots roots which are $x0 and $x1. \n";
161 Jonathan Leto
<jonathan@leto.net
> and Thierry Moisan
<thierry.moisan@gmail.com
>
163 =head1 COPYRIGHT
AND LICENSE
165 Copyright
(C
) 2008 Jonathan Leto and Thierry Moisan
167 This program is free software
; you can redistribute it and
/or modify it
168 under the same terms as Perl itself.