3 #include
"/usr/include/stdio.h"
4 #include
"/usr/local/include/gsl/gsl_vector.h"
5 #include
"/usr/local/include/gsl/gsl_vector_char.h"
6 #include
"/usr/local/include/gsl/gsl_vector_complex.h"
7 #include
"/usr/local/include/gsl/gsl_vector_complex_double.h"
8 #include
"/usr/local/include/gsl/gsl_vector_double.h"
9 #include
"/usr/local/include/gsl/gsl_vector_float.h"
10 #include
"/usr/local/include/gsl/gsl_vector_int.h"
12 %include
"/usr/local/include/gsl/gsl_vector.h"
13 %include
"/usr/local/include/gsl/gsl_vector_char.h"
14 %include
"/usr/local/include/gsl/gsl_vector_complex.h"
15 %include
"/usr/local/include/gsl/gsl_vector_complex_double.h"
16 %include
"/usr/local/include/gsl/gsl_vector_double.h"
17 %include
"/usr/local/include/gsl/gsl_vector_int.h"
19 FILE *fopen
(char
*, char
*);
25 @EXPORT_OK
= qw
/fopen fclose
26 gsl_vector_alloc gsl_vector_calloc gsl_vector_alloc_from_b gsl_vector_alloc_from_v
27 gsl_vector_free gsl_vector_view_array gsl_vector_view_array_w
28 gsl_vector_const_view_a gsl_vector_subvector gsl_vector_subvector_wi
29 gsl_vector_const_subvec gsl_vector_const_subvec gsl_vector_get gsl_vector_set
30 gsl_vector_ptr gsl_vector_const_ptr gsl_vector_set_zero gsl_vector_set_all
31 gsl_vector_set_basis gsl_vector_fread gsl_vector_fwrite gsl_vector_fscanf
32 gsl_vector_fprintf gsl_vector_memcpy gsl_vector_reverse gsl_vector_swap
33 gsl_vector_swap_element gsl_vector_max gsl_vector_min gsl_vector_minmax
34 gsl_vector_max_index gsl_vector_min_index gsl_vector_minmax_index
35 gsl_vector_add gsl_vector_sub gsl_vector_mul gsl_vector_div
36 gsl_vector_scale gsl_vector_add_constant gsl_vector_isnull
37 gsl_vector_ispos gsl_vector_isneg gsl_vector_isnonneg
39 %EXPORT_TAGS
= ( all
=> [ @EXPORT_OK
] );
42 my
($class
, $values
) = @_
;
43 my $length
= $#$values
;
45 die __PACKAGE__.'
::new
($x
) - $x must be an int or nonempty array reference'
46 if
( !(defined $values
) ||
($length
== -1));
48 if
( ref $values eq 'ARRAY'
){
49 $vector
= gsl_vector_alloc
($length
+1);
50 map
{ gsl_vector_set
($vector
, $_
, $values-
>[$_
] ) } (0 .. $length
);
51 } elsif
( int $values
== $values
&& $values > 0) {
52 $vector
= gsl_vector_alloc
($length
);
54 die __PACKAGE__.'
::new
($x
) - $x must be an int or array reference'
;
57 $self-
>{_vector
} = $vector
;
62 my
($self
, $indices
) = @_
;
63 return map
{ gsl_vector_get
($self-
>{_vector
}, $_
) } @$indices
;
67 my
($self
, $indices
, $values
) = @_
;
68 die
(__PACKAGE__.'
::set
($indices
, $values
) - $indices and $values must be array references of the same length'
)
69 unless
( ref $indices eq 'ARRAY'
&& ref $values eq 'ARRAY' && $#$indices == $#$values );
71 map
{ gsl_vector_set
($self-
>{_vector
}, $indices-
>[$_
], $values-
>[$_
] ) } (0..$#$indices
);
81 Functions concerning Vectors.
85 use Math
::GSL
::Vector qw
/:all
/;
89 Here is a list of all the functions included in this module
:
91 gsl_vector_alloc
($x
) - create a vector of size $x
93 gsl_vector_calloc
($x
) - create a vector of size $x and initializes all the elements of the vector to zero
95 gsl_vector_alloc_from_b
97 gsl_vector_alloc_from_v
99 gsl_vector_free
($v
) - free a previously allocated vector $v
101 gsl_vector_view_array
103 gsl_vector_view_array_w
105 gsl_vector_const_view_a
109 gsl_vector_subvector_wi
111 gsl_vector_const_subvec
113 gsl_vector_const_subvec
115 gsl_vector_get
($v
, $i
) - return the $i-th element of a vector $v
117 gsl_vector_set
($v
, $i
, $x
) - return the vector $v with his $i-th element set to $x
143 gsl_vector_swap_element
155 gsl_vector_minmax_index
167 gsl_vector_add_constant
177 You have to add the functions you want to use inside the qw
/put_funtion_here
/ with spaces between each function. You can also write use Math
::GSL
::Complex qw
/:all
/ to use all avaible functions of the module.
179 For more informations on the functions
, we refer you to the GSL offcial documentation
: http
://www.gnu.org
/software
/gsl
/manual
/html_node
/
180 Tip
: search on google
: site
:http
://www.gnu.org
/software
/gsl
/manual
/html_node
/ name_of_the_function_you_want
187 Jonathan Leto
<jonathan@leto.net
> and Thierry Moisan
<thierry.moisan@gmail.com
>
189 =head1 COPYRIGHT
AND LICENSE
191 Copyright
(C
) 2008 Jonathan Leto and Thierry Moisan
193 This program is free software
; you can redistribute it and
/or modify it
194 under the same terms as Perl itself.