| 1 | # This file was automatically generated by SWIG (https://www.swig.org). | ||
| 2 | # Version 4.2.0 | ||
| 3 | # | ||
| 4 | # Do not make changes to this file unless you know what you are doing - modify | ||
| 5 | # the SWIG interface file instead. | ||
| 6 | |||
| 7 | package Math::GSL::Vector; | ||
| 8 | use base qw(Exporter); | ||
| 9 | use base qw(DynaLoader); | ||
| 10 | package Math::GSL::Vectorc; | ||
| 11 | bootstrap Math::GSL::Vector; | ||
| 12 | package Math::GSL::Vector; | ||
| 13 | @EXPORT = qw(); | ||
| 14 | |||
| 15 | # ---------- BASE METHODS ------------- | ||
| 16 | |||
| 17 | package Math::GSL::Vector; | ||
| 18 | |||
| 19 | sub TIEHASH { | ||
| 20 | my ($classname,$obj) = @_; | ||
| 21 | return bless $obj, $classname; | ||
| 22 | } | ||
| 23 | |||
| 24 | sub CLEAR { } | ||
| 25 | |||
| 26 | sub FIRSTKEY { } | ||
| 27 | |||
| 28 | sub NEXTKEY { } | ||
| 29 | |||
| 30 | sub FETCH { | ||
| 31 | my ($self,$field) = @_; | ||
| 32 | my $member_func = "swig_${field}_get"; | ||
| 33 | $self->$member_func(); | ||
| 34 | } | ||
| 35 | |||
| 36 | sub STORE { | ||
| 37 | my ($self,$field,$newval) = @_; | ||
| 38 | my $member_func = "swig_${field}_set"; | ||
| 39 | $self->$member_func($newval); | ||
| 40 | } | ||
| 41 | |||
| 42 | sub this { | ||
| 43 | my $ptr = shift; | ||
| 44 | return tied(%$ptr); | ||
| 45 | } | ||
| 46 | |||
| 47 | |||
| 48 | # ------- FUNCTION WRAPPERS -------- | ||
| 49 | |||
| 50 | package Math::GSL::Vector; | ||
| 51 | |||
| 52 | *gsl_error = *Math::GSL::Vectorc::gsl_error; | ||
| 53 | *gsl_stream_printf = *Math::GSL::Vectorc::gsl_stream_printf; | ||
| 54 | *gsl_strerror = *Math::GSL::Vectorc::gsl_strerror; | ||
| 55 | *gsl_set_error_handler = *Math::GSL::Vectorc::gsl_set_error_handler; | ||
| 56 | *gsl_set_error_handler_off = *Math::GSL::Vectorc::gsl_set_error_handler_off; | ||
| 57 | *gsl_set_stream_handler = *Math::GSL::Vectorc::gsl_set_stream_handler; | ||
| 58 | *gsl_set_stream = *Math::GSL::Vectorc::gsl_set_stream; | ||
| 59 | *fopen = *Math::GSL::Vectorc::fopen; | ||
| 60 | *fclose = *Math::GSL::Vectorc::fclose; | ||
| 61 | *gsl_vector_char_alloc = *Math::GSL::Vectorc::gsl_vector_char_alloc; | ||
| 62 | *gsl_vector_char_calloc = *Math::GSL::Vectorc::gsl_vector_char_calloc; | ||
| 63 | *gsl_vector_char_alloc_from_block = *Math::GSL::Vectorc::gsl_vector_char_alloc_from_block; | ||
| 64 | *gsl_vector_char_alloc_from_vector = *Math::GSL::Vectorc::gsl_vector_char_alloc_from_vector; | ||
| 65 | *gsl_vector_char_free = *Math::GSL::Vectorc::gsl_vector_char_free; | ||
| 66 | *gsl_vector_char_view_array = *Math::GSL::Vectorc::gsl_vector_char_view_array; | ||
| 67 | *gsl_vector_char_view_array_with_stride = *Math::GSL::Vectorc::gsl_vector_char_view_array_with_stride; | ||
| 68 | *gsl_vector_char_const_view_array = *Math::GSL::Vectorc::gsl_vector_char_const_view_array; | ||
| 69 | *gsl_vector_char_const_view_array_with_stride = *Math::GSL::Vectorc::gsl_vector_char_const_view_array_with_stride; | ||
| 70 | *gsl_vector_char_subvector = *Math::GSL::Vectorc::gsl_vector_char_subvector; | ||
| 71 | *gsl_vector_char_subvector_with_stride = *Math::GSL::Vectorc::gsl_vector_char_subvector_with_stride; | ||
| 72 | *gsl_vector_char_const_subvector = *Math::GSL::Vectorc::gsl_vector_char_const_subvector; | ||
| 73 | *gsl_vector_char_const_subvector_with_stride = *Math::GSL::Vectorc::gsl_vector_char_const_subvector_with_stride; | ||
| 74 | *gsl_vector_char_set_zero = *Math::GSL::Vectorc::gsl_vector_char_set_zero; | ||
| 75 | *gsl_vector_char_set_all = *Math::GSL::Vectorc::gsl_vector_char_set_all; | ||
| 76 | *gsl_vector_char_set_basis = *Math::GSL::Vectorc::gsl_vector_char_set_basis; | ||
| 77 | *gsl_vector_char_fread = *Math::GSL::Vectorc::gsl_vector_char_fread; | ||
| 78 | *gsl_vector_char_fwrite = *Math::GSL::Vectorc::gsl_vector_char_fwrite; | ||
| 79 | *gsl_vector_char_fscanf = *Math::GSL::Vectorc::gsl_vector_char_fscanf; | ||
| 80 | *gsl_vector_char_fprintf = *Math::GSL::Vectorc::gsl_vector_char_fprintf; | ||
| 81 | *gsl_vector_char_memcpy = *Math::GSL::Vectorc::gsl_vector_char_memcpy; | ||
| 82 | *gsl_vector_char_reverse = *Math::GSL::Vectorc::gsl_vector_char_reverse; | ||
| 83 | *gsl_vector_char_swap = *Math::GSL::Vectorc::gsl_vector_char_swap; | ||
| 84 | *gsl_vector_char_swap_elements = *Math::GSL::Vectorc::gsl_vector_char_swap_elements; | ||
| 85 | *gsl_vector_char_max = *Math::GSL::Vectorc::gsl_vector_char_max; | ||
| 86 | *gsl_vector_char_min = *Math::GSL::Vectorc::gsl_vector_char_min; | ||
| 87 | *gsl_vector_char_minmax = *Math::GSL::Vectorc::gsl_vector_char_minmax; | ||
| 88 | *gsl_vector_char_max_index = *Math::GSL::Vectorc::gsl_vector_char_max_index; | ||
| 89 | *gsl_vector_char_min_index = *Math::GSL::Vectorc::gsl_vector_char_min_index; | ||
| 90 | *gsl_vector_char_minmax_index = *Math::GSL::Vectorc::gsl_vector_char_minmax_index; | ||
| 91 | *gsl_vector_char_add = *Math::GSL::Vectorc::gsl_vector_char_add; | ||
| 92 | *gsl_vector_char_sub = *Math::GSL::Vectorc::gsl_vector_char_sub; | ||
| 93 | *gsl_vector_char_mul = *Math::GSL::Vectorc::gsl_vector_char_mul; | ||
| 94 | *gsl_vector_char_div = *Math::GSL::Vectorc::gsl_vector_char_div; | ||
| 95 | *gsl_vector_char_scale = *Math::GSL::Vectorc::gsl_vector_char_scale; | ||
| 96 | *gsl_vector_char_add_constant = *Math::GSL::Vectorc::gsl_vector_char_add_constant; | ||
| 97 | *gsl_vector_char_axpby = *Math::GSL::Vectorc::gsl_vector_char_axpby; | ||
| 98 | *gsl_vector_char_sum = *Math::GSL::Vectorc::gsl_vector_char_sum; | ||
| 99 | *gsl_vector_char_equal = *Math::GSL::Vectorc::gsl_vector_char_equal; | ||
| 100 | *gsl_vector_char_isnull = *Math::GSL::Vectorc::gsl_vector_char_isnull; | ||
| 101 | *gsl_vector_char_ispos = *Math::GSL::Vectorc::gsl_vector_char_ispos; | ||
| 102 | *gsl_vector_char_isneg = *Math::GSL::Vectorc::gsl_vector_char_isneg; | ||
| 103 | *gsl_vector_char_isnonneg = *Math::GSL::Vectorc::gsl_vector_char_isnonneg; | ||
| 104 | *gsl_vector_char_get = *Math::GSL::Vectorc::gsl_vector_char_get; | ||
| 105 | *gsl_vector_char_set = *Math::GSL::Vectorc::gsl_vector_char_set; | ||
| 106 | *gsl_vector_char_ptr = *Math::GSL::Vectorc::gsl_vector_char_ptr; | ||
| 107 | *gsl_vector_char_const_ptr = *Math::GSL::Vectorc::gsl_vector_char_const_ptr; | ||
| 108 | *gsl_vector_complex_alloc = *Math::GSL::Vectorc::gsl_vector_complex_alloc; | ||
| 109 | *gsl_vector_complex_calloc = *Math::GSL::Vectorc::gsl_vector_complex_calloc; | ||
| 110 | *gsl_vector_complex_alloc_from_block = *Math::GSL::Vectorc::gsl_vector_complex_alloc_from_block; | ||
| 111 | *gsl_vector_complex_alloc_from_vector = *Math::GSL::Vectorc::gsl_vector_complex_alloc_from_vector; | ||
| 112 | *gsl_vector_complex_free = *Math::GSL::Vectorc::gsl_vector_complex_free; | ||
| 113 | *gsl_vector_complex_view_array = *Math::GSL::Vectorc::gsl_vector_complex_view_array; | ||
| 114 | *gsl_vector_complex_view_array_with_stride = *Math::GSL::Vectorc::gsl_vector_complex_view_array_with_stride; | ||
| 115 | *gsl_vector_complex_const_view_array = *Math::GSL::Vectorc::gsl_vector_complex_const_view_array; | ||
| 116 | *gsl_vector_complex_const_view_array_with_stride = *Math::GSL::Vectorc::gsl_vector_complex_const_view_array_with_stride; | ||
| 117 | *gsl_vector_complex_subvector = *Math::GSL::Vectorc::gsl_vector_complex_subvector; | ||
| 118 | *gsl_vector_complex_subvector_with_stride = *Math::GSL::Vectorc::gsl_vector_complex_subvector_with_stride; | ||
| 119 | *gsl_vector_complex_const_subvector = *Math::GSL::Vectorc::gsl_vector_complex_const_subvector; | ||
| 120 | *gsl_vector_complex_const_subvector_with_stride = *Math::GSL::Vectorc::gsl_vector_complex_const_subvector_with_stride; | ||
| 121 | *gsl_vector_complex_real = *Math::GSL::Vectorc::gsl_vector_complex_real; | ||
| 122 | *gsl_vector_complex_imag = *Math::GSL::Vectorc::gsl_vector_complex_imag; | ||
| 123 | *gsl_vector_complex_const_real = *Math::GSL::Vectorc::gsl_vector_complex_const_real; | ||
| 124 | *gsl_vector_complex_const_imag = *Math::GSL::Vectorc::gsl_vector_complex_const_imag; | ||
| 125 | *gsl_vector_complex_set_zero = *Math::GSL::Vectorc::gsl_vector_complex_set_zero; | ||
| 126 | *gsl_vector_complex_set_all = *Math::GSL::Vectorc::gsl_vector_complex_set_all; | ||
| 127 | *gsl_vector_complex_set_basis = *Math::GSL::Vectorc::gsl_vector_complex_set_basis; | ||
| 128 | *gsl_vector_complex_fread = *Math::GSL::Vectorc::gsl_vector_complex_fread; | ||
| 129 | *gsl_vector_complex_fwrite = *Math::GSL::Vectorc::gsl_vector_complex_fwrite; | ||
| 130 | *gsl_vector_complex_fscanf = *Math::GSL::Vectorc::gsl_vector_complex_fscanf; | ||
| 131 | *gsl_vector_complex_fprintf = *Math::GSL::Vectorc::gsl_vector_complex_fprintf; | ||
| 132 | *gsl_vector_complex_memcpy = *Math::GSL::Vectorc::gsl_vector_complex_memcpy; | ||
| 133 | *gsl_vector_complex_conj_memcpy = *Math::GSL::Vectorc::gsl_vector_complex_conj_memcpy; | ||
| 134 | *gsl_vector_complex_reverse = *Math::GSL::Vectorc::gsl_vector_complex_reverse; | ||
| 135 | *gsl_vector_complex_swap = *Math::GSL::Vectorc::gsl_vector_complex_swap; | ||
| 136 | *gsl_vector_complex_swap_elements = *Math::GSL::Vectorc::gsl_vector_complex_swap_elements; | ||
| 137 | *gsl_vector_complex_equal = *Math::GSL::Vectorc::gsl_vector_complex_equal; | ||
| 138 | *gsl_vector_complex_isnull = *Math::GSL::Vectorc::gsl_vector_complex_isnull; | ||
| 139 | *gsl_vector_complex_ispos = *Math::GSL::Vectorc::gsl_vector_complex_ispos; | ||
| 140 | *gsl_vector_complex_isneg = *Math::GSL::Vectorc::gsl_vector_complex_isneg; | ||
| 141 | *gsl_vector_complex_isnonneg = *Math::GSL::Vectorc::gsl_vector_complex_isnonneg; | ||
| 142 | *gsl_vector_complex_add = *Math::GSL::Vectorc::gsl_vector_complex_add; | ||
| 143 | *gsl_vector_complex_sub = *Math::GSL::Vectorc::gsl_vector_complex_sub; | ||
| 144 | *gsl_vector_complex_mul = *Math::GSL::Vectorc::gsl_vector_complex_mul; | ||
| 145 | *gsl_vector_complex_div = *Math::GSL::Vectorc::gsl_vector_complex_div; | ||
| 146 | *gsl_vector_complex_scale = *Math::GSL::Vectorc::gsl_vector_complex_scale; | ||
| 147 | *gsl_vector_complex_add_constant = *Math::GSL::Vectorc::gsl_vector_complex_add_constant; | ||
| 148 | *gsl_vector_complex_axpby = *Math::GSL::Vectorc::gsl_vector_complex_axpby; | ||
| 149 | *gsl_vector_complex_div_real = *Math::GSL::Vectorc::gsl_vector_complex_div_real; | ||
| 150 | *gsl_vector_complex_get = *Math::GSL::Vectorc::gsl_vector_complex_get; | ||
| 151 | *gsl_vector_complex_set = *Math::GSL::Vectorc::gsl_vector_complex_set; | ||
| 152 | *gsl_vector_complex_ptr = *Math::GSL::Vectorc::gsl_vector_complex_ptr; | ||
| 153 | *gsl_vector_complex_const_ptr = *Math::GSL::Vectorc::gsl_vector_complex_const_ptr; | ||
| 154 | *gsl_vector_alloc = *Math::GSL::Vectorc::gsl_vector_alloc; | ||
| 155 | *gsl_vector_calloc = *Math::GSL::Vectorc::gsl_vector_calloc; | ||
| 156 | *gsl_vector_alloc_from_block = *Math::GSL::Vectorc::gsl_vector_alloc_from_block; | ||
| 157 | *gsl_vector_alloc_from_vector = *Math::GSL::Vectorc::gsl_vector_alloc_from_vector; | ||
| 158 | *gsl_vector_free = *Math::GSL::Vectorc::gsl_vector_free; | ||
| 159 | *gsl_vector_view_array = *Math::GSL::Vectorc::gsl_vector_view_array; | ||
| 160 | *gsl_vector_view_array_with_stride = *Math::GSL::Vectorc::gsl_vector_view_array_with_stride; | ||
| 161 | *gsl_vector_const_view_array = *Math::GSL::Vectorc::gsl_vector_const_view_array; | ||
| 162 | *gsl_vector_const_view_array_with_stride = *Math::GSL::Vectorc::gsl_vector_const_view_array_with_stride; | ||
| 163 | *gsl_vector_subvector = *Math::GSL::Vectorc::gsl_vector_subvector; | ||
| 164 | *gsl_vector_subvector_with_stride = *Math::GSL::Vectorc::gsl_vector_subvector_with_stride; | ||
| 165 | *gsl_vector_const_subvector = *Math::GSL::Vectorc::gsl_vector_const_subvector; | ||
| 166 | *gsl_vector_const_subvector_with_stride = *Math::GSL::Vectorc::gsl_vector_const_subvector_with_stride; | ||
| 167 | *gsl_vector_set_zero = *Math::GSL::Vectorc::gsl_vector_set_zero; | ||
| 168 | *gsl_vector_set_all = *Math::GSL::Vectorc::gsl_vector_set_all; | ||
| 169 | *gsl_vector_set_basis = *Math::GSL::Vectorc::gsl_vector_set_basis; | ||
| 170 | *gsl_vector_fread = *Math::GSL::Vectorc::gsl_vector_fread; | ||
| 171 | *gsl_vector_fwrite = *Math::GSL::Vectorc::gsl_vector_fwrite; | ||
| 172 | *gsl_vector_fscanf = *Math::GSL::Vectorc::gsl_vector_fscanf; | ||
| 173 | *gsl_vector_fprintf = *Math::GSL::Vectorc::gsl_vector_fprintf; | ||
| 174 | *gsl_vector_memcpy = *Math::GSL::Vectorc::gsl_vector_memcpy; | ||
| 175 | *gsl_vector_reverse = *Math::GSL::Vectorc::gsl_vector_reverse; | ||
| 176 | *gsl_vector_swap = *Math::GSL::Vectorc::gsl_vector_swap; | ||
| 177 | *gsl_vector_swap_elements = *Math::GSL::Vectorc::gsl_vector_swap_elements; | ||
| 178 | *gsl_vector_max = *Math::GSL::Vectorc::gsl_vector_max; | ||
| 179 | *gsl_vector_min = *Math::GSL::Vectorc::gsl_vector_min; | ||
| 180 | *gsl_vector_minmax = *Math::GSL::Vectorc::gsl_vector_minmax; | ||
| 181 | *gsl_vector_max_index = *Math::GSL::Vectorc::gsl_vector_max_index; | ||
| 182 | *gsl_vector_min_index = *Math::GSL::Vectorc::gsl_vector_min_index; | ||
| 183 | *gsl_vector_minmax_index = *Math::GSL::Vectorc::gsl_vector_minmax_index; | ||
| 184 | *gsl_vector_add = *Math::GSL::Vectorc::gsl_vector_add; | ||
| 185 | *gsl_vector_sub = *Math::GSL::Vectorc::gsl_vector_sub; | ||
| 186 | *gsl_vector_mul = *Math::GSL::Vectorc::gsl_vector_mul; | ||
| 187 | *gsl_vector_div = *Math::GSL::Vectorc::gsl_vector_div; | ||
| 188 | *gsl_vector_scale = *Math::GSL::Vectorc::gsl_vector_scale; | ||
| 189 | *gsl_vector_add_constant = *Math::GSL::Vectorc::gsl_vector_add_constant; | ||
| 190 | *gsl_vector_axpby = *Math::GSL::Vectorc::gsl_vector_axpby; | ||
| 191 | *gsl_vector_sum = *Math::GSL::Vectorc::gsl_vector_sum; | ||
| 192 | *gsl_vector_equal = *Math::GSL::Vectorc::gsl_vector_equal; | ||
| 193 | *gsl_vector_isnull = *Math::GSL::Vectorc::gsl_vector_isnull; | ||
| 194 | *gsl_vector_ispos = *Math::GSL::Vectorc::gsl_vector_ispos; | ||
| 195 | *gsl_vector_isneg = *Math::GSL::Vectorc::gsl_vector_isneg; | ||
| 196 | *gsl_vector_isnonneg = *Math::GSL::Vectorc::gsl_vector_isnonneg; | ||
| 197 | *gsl_vector_get = *Math::GSL::Vectorc::gsl_vector_get; | ||
| 198 | *gsl_vector_set = *Math::GSL::Vectorc::gsl_vector_set; | ||
| 199 | *gsl_vector_ptr = *Math::GSL::Vectorc::gsl_vector_ptr; | ||
| 200 | *gsl_vector_const_ptr = *Math::GSL::Vectorc::gsl_vector_const_ptr; | ||
| 201 | *gsl_vector_int_alloc = *Math::GSL::Vectorc::gsl_vector_int_alloc; | ||
| 202 | *gsl_vector_int_calloc = *Math::GSL::Vectorc::gsl_vector_int_calloc; | ||
| 203 | *gsl_vector_int_alloc_from_block = *Math::GSL::Vectorc::gsl_vector_int_alloc_from_block; | ||
| 204 | *gsl_vector_int_alloc_from_vector = *Math::GSL::Vectorc::gsl_vector_int_alloc_from_vector; | ||
| 205 | *gsl_vector_int_free = *Math::GSL::Vectorc::gsl_vector_int_free; | ||
| 206 | *gsl_vector_int_view_array = *Math::GSL::Vectorc::gsl_vector_int_view_array; | ||
| 207 | *gsl_vector_int_view_array_with_stride = *Math::GSL::Vectorc::gsl_vector_int_view_array_with_stride; | ||
| 208 | *gsl_vector_int_const_view_array = *Math::GSL::Vectorc::gsl_vector_int_const_view_array; | ||
| 209 | *gsl_vector_int_const_view_array_with_stride = *Math::GSL::Vectorc::gsl_vector_int_const_view_array_with_stride; | ||
| 210 | *gsl_vector_int_subvector = *Math::GSL::Vectorc::gsl_vector_int_subvector; | ||
| 211 | *gsl_vector_int_subvector_with_stride = *Math::GSL::Vectorc::gsl_vector_int_subvector_with_stride; | ||
| 212 | *gsl_vector_int_const_subvector = *Math::GSL::Vectorc::gsl_vector_int_const_subvector; | ||
| 213 | *gsl_vector_int_const_subvector_with_stride = *Math::GSL::Vectorc::gsl_vector_int_const_subvector_with_stride; | ||
| 214 | *gsl_vector_int_set_zero = *Math::GSL::Vectorc::gsl_vector_int_set_zero; | ||
| 215 | *gsl_vector_int_set_all = *Math::GSL::Vectorc::gsl_vector_int_set_all; | ||
| 216 | *gsl_vector_int_set_basis = *Math::GSL::Vectorc::gsl_vector_int_set_basis; | ||
| 217 | *gsl_vector_int_fread = *Math::GSL::Vectorc::gsl_vector_int_fread; | ||
| 218 | *gsl_vector_int_fwrite = *Math::GSL::Vectorc::gsl_vector_int_fwrite; | ||
| 219 | *gsl_vector_int_fscanf = *Math::GSL::Vectorc::gsl_vector_int_fscanf; | ||
| 220 | *gsl_vector_int_fprintf = *Math::GSL::Vectorc::gsl_vector_int_fprintf; | ||
| 221 | *gsl_vector_int_memcpy = *Math::GSL::Vectorc::gsl_vector_int_memcpy; | ||
| 222 | *gsl_vector_int_reverse = *Math::GSL::Vectorc::gsl_vector_int_reverse; | ||
| 223 | *gsl_vector_int_swap = *Math::GSL::Vectorc::gsl_vector_int_swap; | ||
| 224 | *gsl_vector_int_swap_elements = *Math::GSL::Vectorc::gsl_vector_int_swap_elements; | ||
| 225 | *gsl_vector_int_max = *Math::GSL::Vectorc::gsl_vector_int_max; | ||
| 226 | *gsl_vector_int_min = *Math::GSL::Vectorc::gsl_vector_int_min; | ||
| 227 | *gsl_vector_int_minmax = *Math::GSL::Vectorc::gsl_vector_int_minmax; | ||
| 228 | *gsl_vector_int_max_index = *Math::GSL::Vectorc::gsl_vector_int_max_index; | ||
| 229 | *gsl_vector_int_min_index = *Math::GSL::Vectorc::gsl_vector_int_min_index; | ||
| 230 | *gsl_vector_int_minmax_index = *Math::GSL::Vectorc::gsl_vector_int_minmax_index; | ||
| 231 | *gsl_vector_int_add = *Math::GSL::Vectorc::gsl_vector_int_add; | ||
| 232 | *gsl_vector_int_sub = *Math::GSL::Vectorc::gsl_vector_int_sub; | ||
| 233 | *gsl_vector_int_mul = *Math::GSL::Vectorc::gsl_vector_int_mul; | ||
| 234 | *gsl_vector_int_div = *Math::GSL::Vectorc::gsl_vector_int_div; | ||
| 235 | *gsl_vector_int_scale = *Math::GSL::Vectorc::gsl_vector_int_scale; | ||
| 236 | *gsl_vector_int_add_constant = *Math::GSL::Vectorc::gsl_vector_int_add_constant; | ||
| 237 | *gsl_vector_int_axpby = *Math::GSL::Vectorc::gsl_vector_int_axpby; | ||
| 238 | *gsl_vector_int_sum = *Math::GSL::Vectorc::gsl_vector_int_sum; | ||
| 239 | *gsl_vector_int_equal = *Math::GSL::Vectorc::gsl_vector_int_equal; | ||
| 240 | *gsl_vector_int_isnull = *Math::GSL::Vectorc::gsl_vector_int_isnull; | ||
| 241 | *gsl_vector_int_ispos = *Math::GSL::Vectorc::gsl_vector_int_ispos; | ||
| 242 | *gsl_vector_int_isneg = *Math::GSL::Vectorc::gsl_vector_int_isneg; | ||
| 243 | *gsl_vector_int_isnonneg = *Math::GSL::Vectorc::gsl_vector_int_isnonneg; | ||
| 244 | *gsl_vector_int_get = *Math::GSL::Vectorc::gsl_vector_int_get; | ||
| 245 | *gsl_vector_int_set = *Math::GSL::Vectorc::gsl_vector_int_set; | ||
| 246 | *gsl_vector_int_ptr = *Math::GSL::Vectorc::gsl_vector_int_ptr; | ||
| 247 | *gsl_vector_int_const_ptr = *Math::GSL::Vectorc::gsl_vector_int_const_ptr; | ||
| 248 | |||
| 249 | ############# Class : Math::GSL::Vector::gsl_vector_char ############## | ||
| 250 | |||
| 251 | package Math::GSL::Vector::gsl_vector_char; | ||
| 252 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 253 | @ISA = qw( Math::GSL::Vector ); | ||
| 254 | %OWNER = (); | ||
| 255 | %ITERATORS = (); | ||
| 256 | *swig_size_get = *Math::GSL::Vectorc::gsl_vector_char_size_get; | ||
| 257 | *swig_size_set = *Math::GSL::Vectorc::gsl_vector_char_size_set; | ||
| 258 | *swig_stride_get = *Math::GSL::Vectorc::gsl_vector_char_stride_get; | ||
| 259 | *swig_stride_set = *Math::GSL::Vectorc::gsl_vector_char_stride_set; | ||
| 260 | *swig_data_get = *Math::GSL::Vectorc::gsl_vector_char_data_get; | ||
| 261 | *swig_data_set = *Math::GSL::Vectorc::gsl_vector_char_data_set; | ||
| 262 | *swig_block_get = *Math::GSL::Vectorc::gsl_vector_char_block_get; | ||
| 263 | *swig_block_set = *Math::GSL::Vectorc::gsl_vector_char_block_set; | ||
| 264 | *swig_owner_get = *Math::GSL::Vectorc::gsl_vector_char_owner_get; | ||
| 265 | *swig_owner_set = *Math::GSL::Vectorc::gsl_vector_char_owner_set; | ||
| 266 | sub new { | ||
| 267 | my $pkg = shift; | ||
| 268 | my $self = Math::GSL::Vectorc::new_gsl_vector_char(@_); | ||
| 269 | bless $self, $pkg if defined($self); | ||
| 270 | } | ||
| 271 | |||
| 272 | sub DESTROY { | ||
| 273 | return unless $_[0]->isa('HASH'); | ||
| 274 | my $self = tied(%{$_[0]}); | ||
| 275 | return unless defined $self; | ||
| 276 | delete $ITERATORS{$self}; | ||
| 277 | if (exists $OWNER{$self}) { | ||
| 278 | Math::GSL::Vectorc::delete_gsl_vector_char($self); | ||
| 279 | delete $OWNER{$self}; | ||
| 280 | } | ||
| 281 | } | ||
| 282 | |||
| 283 | sub DISOWN { | ||
| 284 | my $self = shift; | ||
| 285 | my $ptr = tied(%$self); | ||
| 286 | delete $OWNER{$ptr}; | ||
| 287 | } | ||
| 288 | |||
| 289 | sub ACQUIRE { | ||
| 290 | my $self = shift; | ||
| 291 | my $ptr = tied(%$self); | ||
| 292 | $OWNER{$ptr} = 1; | ||
| 293 | } | ||
| 294 | |||
| 295 | |||
| 296 | ############# Class : Math::GSL::Vector::_gsl_vector_char_view ############## | ||
| 297 | |||
| 298 | package Math::GSL::Vector::_gsl_vector_char_view; | ||
| 299 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 300 | @ISA = qw( Math::GSL::Vector ); | ||
| 301 | %OWNER = (); | ||
| 302 | %ITERATORS = (); | ||
| 303 | *swig_vector_get = *Math::GSL::Vectorc::_gsl_vector_char_view_vector_get; | ||
| 304 | *swig_vector_set = *Math::GSL::Vectorc::_gsl_vector_char_view_vector_set; | ||
| 305 | sub new { | ||
| 306 | my $pkg = shift; | ||
| 307 | my $self = Math::GSL::Vectorc::new__gsl_vector_char_view(@_); | ||
| 308 | bless $self, $pkg if defined($self); | ||
| 309 | } | ||
| 310 | |||
| 311 | sub DESTROY { | ||
| 312 | return unless $_[0]->isa('HASH'); | ||
| 313 | my $self = tied(%{$_[0]}); | ||
| 314 | return unless defined $self; | ||
| 315 | delete $ITERATORS{$self}; | ||
| 316 | if (exists $OWNER{$self}) { | ||
| 317 | Math::GSL::Vectorc::delete__gsl_vector_char_view($self); | ||
| 318 | delete $OWNER{$self}; | ||
| 319 | } | ||
| 320 | } | ||
| 321 | |||
| 322 | sub DISOWN { | ||
| 323 | my $self = shift; | ||
| 324 | my $ptr = tied(%$self); | ||
| 325 | delete $OWNER{$ptr}; | ||
| 326 | } | ||
| 327 | |||
| 328 | sub ACQUIRE { | ||
| 329 | my $self = shift; | ||
| 330 | my $ptr = tied(%$self); | ||
| 331 | $OWNER{$ptr} = 1; | ||
| 332 | } | ||
| 333 | |||
| 334 | |||
| 335 | ############# Class : Math::GSL::Vector::_gsl_vector_char_const_view ############## | ||
| 336 | |||
| 337 | package Math::GSL::Vector::_gsl_vector_char_const_view; | ||
| 338 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 339 | @ISA = qw( Math::GSL::Vector ); | ||
| 340 | %OWNER = (); | ||
| 341 | %ITERATORS = (); | ||
| 342 | *swig_vector_get = *Math::GSL::Vectorc::_gsl_vector_char_const_view_vector_get; | ||
| 343 | *swig_vector_set = *Math::GSL::Vectorc::_gsl_vector_char_const_view_vector_set; | ||
| 344 | sub new { | ||
| 345 | my $pkg = shift; | ||
| 346 | my $self = Math::GSL::Vectorc::new__gsl_vector_char_const_view(@_); | ||
| 347 | bless $self, $pkg if defined($self); | ||
| 348 | } | ||
| 349 | |||
| 350 | sub DESTROY { | ||
| 351 | return unless $_[0]->isa('HASH'); | ||
| 352 | my $self = tied(%{$_[0]}); | ||
| 353 | return unless defined $self; | ||
| 354 | delete $ITERATORS{$self}; | ||
| 355 | if (exists $OWNER{$self}) { | ||
| 356 | Math::GSL::Vectorc::delete__gsl_vector_char_const_view($self); | ||
| 357 | delete $OWNER{$self}; | ||
| 358 | } | ||
| 359 | } | ||
| 360 | |||
| 361 | sub DISOWN { | ||
| 362 | my $self = shift; | ||
| 363 | my $ptr = tied(%$self); | ||
| 364 | delete $OWNER{$ptr}; | ||
| 365 | } | ||
| 366 | |||
| 367 | sub ACQUIRE { | ||
| 368 | my $self = shift; | ||
| 369 | my $ptr = tied(%$self); | ||
| 370 | $OWNER{$ptr} = 1; | ||
| 371 | } | ||
| 372 | |||
| 373 | |||
| 374 | ############# Class : Math::GSL::Vector::gsl_vector_complex ############## | ||
| 375 | |||
| 376 | package Math::GSL::Vector::gsl_vector_complex; | ||
| 377 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 378 | @ISA = qw( Math::GSL::Vector ); | ||
| 379 | %OWNER = (); | ||
| 380 | %ITERATORS = (); | ||
| 381 | *swig_size_get = *Math::GSL::Vectorc::gsl_vector_complex_size_get; | ||
| 382 | *swig_size_set = *Math::GSL::Vectorc::gsl_vector_complex_size_set; | ||
| 383 | *swig_stride_get = *Math::GSL::Vectorc::gsl_vector_complex_stride_get; | ||
| 384 | *swig_stride_set = *Math::GSL::Vectorc::gsl_vector_complex_stride_set; | ||
| 385 | *swig_data_get = *Math::GSL::Vectorc::gsl_vector_complex_data_get; | ||
| 386 | *swig_data_set = *Math::GSL::Vectorc::gsl_vector_complex_data_set; | ||
| 387 | *swig_block_get = *Math::GSL::Vectorc::gsl_vector_complex_block_get; | ||
| 388 | *swig_block_set = *Math::GSL::Vectorc::gsl_vector_complex_block_set; | ||
| 389 | *swig_owner_get = *Math::GSL::Vectorc::gsl_vector_complex_owner_get; | ||
| 390 | *swig_owner_set = *Math::GSL::Vectorc::gsl_vector_complex_owner_set; | ||
| 391 | sub new { | ||
| 392 | my $pkg = shift; | ||
| 393 | my $self = Math::GSL::Vectorc::new_gsl_vector_complex(@_); | ||
| 394 | bless $self, $pkg if defined($self); | ||
| 395 | } | ||
| 396 | |||
| 397 | sub DESTROY { | ||
| 398 | return unless $_[0]->isa('HASH'); | ||
| 399 | my $self = tied(%{$_[0]}); | ||
| 400 | return unless defined $self; | ||
| 401 | delete $ITERATORS{$self}; | ||
| 402 | if (exists $OWNER{$self}) { | ||
| 403 | Math::GSL::Vectorc::delete_gsl_vector_complex($self); | ||
| 404 | delete $OWNER{$self}; | ||
| 405 | } | ||
| 406 | } | ||
| 407 | |||
| 408 | sub DISOWN { | ||
| 409 | my $self = shift; | ||
| 410 | my $ptr = tied(%$self); | ||
| 411 | delete $OWNER{$ptr}; | ||
| 412 | } | ||
| 413 | |||
| 414 | sub ACQUIRE { | ||
| 415 | my $self = shift; | ||
| 416 | my $ptr = tied(%$self); | ||
| 417 | $OWNER{$ptr} = 1; | ||
| 418 | } | ||
| 419 | |||
| 420 | |||
| 421 | ############# Class : Math::GSL::Vector::_gsl_vector_complex_view ############## | ||
| 422 | |||
| 423 | package Math::GSL::Vector::_gsl_vector_complex_view; | ||
| 424 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 425 | @ISA = qw( Math::GSL::Vector ); | ||
| 426 | %OWNER = (); | ||
| 427 | %ITERATORS = (); | ||
| 428 | *swig_vector_get = *Math::GSL::Vectorc::_gsl_vector_complex_view_vector_get; | ||
| 429 | *swig_vector_set = *Math::GSL::Vectorc::_gsl_vector_complex_view_vector_set; | ||
| 430 | sub new { | ||
| 431 | my $pkg = shift; | ||
| 432 | my $self = Math::GSL::Vectorc::new__gsl_vector_complex_view(@_); | ||
| 433 | bless $self, $pkg if defined($self); | ||
| 434 | } | ||
| 435 | |||
| 436 | sub DESTROY { | ||
| 437 | return unless $_[0]->isa('HASH'); | ||
| 438 | my $self = tied(%{$_[0]}); | ||
| 439 | return unless defined $self; | ||
| 440 | delete $ITERATORS{$self}; | ||
| 441 | if (exists $OWNER{$self}) { | ||
| 442 | Math::GSL::Vectorc::delete__gsl_vector_complex_view($self); | ||
| 443 | delete $OWNER{$self}; | ||
| 444 | } | ||
| 445 | } | ||
| 446 | |||
| 447 | sub DISOWN { | ||
| 448 | my $self = shift; | ||
| 449 | my $ptr = tied(%$self); | ||
| 450 | delete $OWNER{$ptr}; | ||
| 451 | } | ||
| 452 | |||
| 453 | sub ACQUIRE { | ||
| 454 | my $self = shift; | ||
| 455 | my $ptr = tied(%$self); | ||
| 456 | $OWNER{$ptr} = 1; | ||
| 457 | } | ||
| 458 | |||
| 459 | |||
| 460 | ############# Class : Math::GSL::Vector::_gsl_vector_complex_const_view ############## | ||
| 461 | |||
| 462 | package Math::GSL::Vector::_gsl_vector_complex_const_view; | ||
| 463 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 464 | @ISA = qw( Math::GSL::Vector ); | ||
| 465 | %OWNER = (); | ||
| 466 | %ITERATORS = (); | ||
| 467 | *swig_vector_get = *Math::GSL::Vectorc::_gsl_vector_complex_const_view_vector_get; | ||
| 468 | *swig_vector_set = *Math::GSL::Vectorc::_gsl_vector_complex_const_view_vector_set; | ||
| 469 | sub new { | ||
| 470 | my $pkg = shift; | ||
| 471 | my $self = Math::GSL::Vectorc::new__gsl_vector_complex_const_view(@_); | ||
| 472 | bless $self, $pkg if defined($self); | ||
| 473 | } | ||
| 474 | |||
| 475 | sub DESTROY { | ||
| 476 | return unless $_[0]->isa('HASH'); | ||
| 477 | my $self = tied(%{$_[0]}); | ||
| 478 | return unless defined $self; | ||
| 479 | delete $ITERATORS{$self}; | ||
| 480 | if (exists $OWNER{$self}) { | ||
| 481 | Math::GSL::Vectorc::delete__gsl_vector_complex_const_view($self); | ||
| 482 | delete $OWNER{$self}; | ||
| 483 | } | ||
| 484 | } | ||
| 485 | |||
| 486 | sub DISOWN { | ||
| 487 | my $self = shift; | ||
| 488 | my $ptr = tied(%$self); | ||
| 489 | delete $OWNER{$ptr}; | ||
| 490 | } | ||
| 491 | |||
| 492 | sub ACQUIRE { | ||
| 493 | my $self = shift; | ||
| 494 | my $ptr = tied(%$self); | ||
| 495 | $OWNER{$ptr} = 1; | ||
| 496 | } | ||
| 497 | |||
| 498 | |||
| 499 | ############# Class : Math::GSL::Vector::gsl_vector ############## | ||
| 500 | |||
| 501 | package Math::GSL::Vector::gsl_vector; | ||
| 502 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 503 | @ISA = qw( Math::GSL::Vector ); | ||
| 504 | %OWNER = (); | ||
| 505 | %ITERATORS = (); | ||
| 506 | *swig_size_get = *Math::GSL::Vectorc::gsl_vector_size_get; | ||
| 507 | *swig_size_set = *Math::GSL::Vectorc::gsl_vector_size_set; | ||
| 508 | *swig_stride_get = *Math::GSL::Vectorc::gsl_vector_stride_get; | ||
| 509 | *swig_stride_set = *Math::GSL::Vectorc::gsl_vector_stride_set; | ||
| 510 | *swig_data_get = *Math::GSL::Vectorc::gsl_vector_data_get; | ||
| 511 | *swig_data_set = *Math::GSL::Vectorc::gsl_vector_data_set; | ||
| 512 | *swig_block_get = *Math::GSL::Vectorc::gsl_vector_block_get; | ||
| 513 | *swig_block_set = *Math::GSL::Vectorc::gsl_vector_block_set; | ||
| 514 | *swig_owner_get = *Math::GSL::Vectorc::gsl_vector_owner_get; | ||
| 515 | *swig_owner_set = *Math::GSL::Vectorc::gsl_vector_owner_set; | ||
| 516 | sub new { | ||
| 517 | my $pkg = shift; | ||
| 518 | my $self = Math::GSL::Vectorc::new_gsl_vector(@_); | ||
| 519 | bless $self, $pkg if defined($self); | ||
| 520 | } | ||
| 521 | |||
| 522 | sub DESTROY { | ||
| 523 | return unless $_[0]->isa('HASH'); | ||
| 524 | my $self = tied(%{$_[0]}); | ||
| 525 | return unless defined $self; | ||
| 526 | delete $ITERATORS{$self}; | ||
| 527 | if (exists $OWNER{$self}) { | ||
| 528 | Math::GSL::Vectorc::delete_gsl_vector($self); | ||
| 529 | delete $OWNER{$self}; | ||
| 530 | } | ||
| 531 | } | ||
| 532 | |||
| 533 | sub DISOWN { | ||
| 534 | my $self = shift; | ||
| 535 | my $ptr = tied(%$self); | ||
| 536 | delete $OWNER{$ptr}; | ||
| 537 | } | ||
| 538 | |||
| 539 | sub ACQUIRE { | ||
| 540 | my $self = shift; | ||
| 541 | my $ptr = tied(%$self); | ||
| 542 | $OWNER{$ptr} = 1; | ||
| 543 | } | ||
| 544 | |||
| 545 | |||
| 546 | ############# Class : Math::GSL::Vector::_gsl_vector_view ############## | ||
| 547 | |||
| 548 | package Math::GSL::Vector::_gsl_vector_view; | ||
| 549 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 550 | @ISA = qw( Math::GSL::Vector ); | ||
| 551 | %OWNER = (); | ||
| 552 | %ITERATORS = (); | ||
| 553 | *swig_vector_get = *Math::GSL::Vectorc::_gsl_vector_view_vector_get; | ||
| 554 | *swig_vector_set = *Math::GSL::Vectorc::_gsl_vector_view_vector_set; | ||
| 555 | sub new { | ||
| 556 | my $pkg = shift; | ||
| 557 | my $self = Math::GSL::Vectorc::new__gsl_vector_view(@_); | ||
| 558 | bless $self, $pkg if defined($self); | ||
| 559 | } | ||
| 560 | |||
| 561 | sub DESTROY { | ||
| 562 | return unless $_[0]->isa('HASH'); | ||
| 563 | my $self = tied(%{$_[0]}); | ||
| 564 | return unless defined $self; | ||
| 565 | delete $ITERATORS{$self}; | ||
| 566 | if (exists $OWNER{$self}) { | ||
| 567 | Math::GSL::Vectorc::delete__gsl_vector_view($self); | ||
| 568 | delete $OWNER{$self}; | ||
| 569 | } | ||
| 570 | } | ||
| 571 | |||
| 572 | sub DISOWN { | ||
| 573 | my $self = shift; | ||
| 574 | my $ptr = tied(%$self); | ||
| 575 | delete $OWNER{$ptr}; | ||
| 576 | } | ||
| 577 | |||
| 578 | sub ACQUIRE { | ||
| 579 | my $self = shift; | ||
| 580 | my $ptr = tied(%$self); | ||
| 581 | $OWNER{$ptr} = 1; | ||
| 582 | } | ||
| 583 | |||
| 584 | |||
| 585 | ############# Class : Math::GSL::Vector::_gsl_vector_const_view ############## | ||
| 586 | |||
| 587 | package Math::GSL::Vector::_gsl_vector_const_view; | ||
| 588 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 589 | @ISA = qw( Math::GSL::Vector ); | ||
| 590 | %OWNER = (); | ||
| 591 | %ITERATORS = (); | ||
| 592 | *swig_vector_get = *Math::GSL::Vectorc::_gsl_vector_const_view_vector_get; | ||
| 593 | *swig_vector_set = *Math::GSL::Vectorc::_gsl_vector_const_view_vector_set; | ||
| 594 | sub new { | ||
| 595 | my $pkg = shift; | ||
| 596 | my $self = Math::GSL::Vectorc::new__gsl_vector_const_view(@_); | ||
| 597 | bless $self, $pkg if defined($self); | ||
| 598 | } | ||
| 599 | |||
| 600 | sub DESTROY { | ||
| 601 | return unless $_[0]->isa('HASH'); | ||
| 602 | my $self = tied(%{$_[0]}); | ||
| 603 | return unless defined $self; | ||
| 604 | delete $ITERATORS{$self}; | ||
| 605 | if (exists $OWNER{$self}) { | ||
| 606 | Math::GSL::Vectorc::delete__gsl_vector_const_view($self); | ||
| 607 | delete $OWNER{$self}; | ||
| 608 | } | ||
| 609 | } | ||
| 610 | |||
| 611 | sub DISOWN { | ||
| 612 | my $self = shift; | ||
| 613 | my $ptr = tied(%$self); | ||
| 614 | delete $OWNER{$ptr}; | ||
| 615 | } | ||
| 616 | |||
| 617 | sub ACQUIRE { | ||
| 618 | my $self = shift; | ||
| 619 | my $ptr = tied(%$self); | ||
| 620 | $OWNER{$ptr} = 1; | ||
| 621 | } | ||
| 622 | |||
| 623 | |||
| 624 | ############# Class : Math::GSL::Vector::gsl_vector_int ############## | ||
| 625 | |||
| 626 | package Math::GSL::Vector::gsl_vector_int; | ||
| 627 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 628 | @ISA = qw( Math::GSL::Vector ); | ||
| 629 | %OWNER = (); | ||
| 630 | %ITERATORS = (); | ||
| 631 | *swig_size_get = *Math::GSL::Vectorc::gsl_vector_int_size_get; | ||
| 632 | *swig_size_set = *Math::GSL::Vectorc::gsl_vector_int_size_set; | ||
| 633 | *swig_stride_get = *Math::GSL::Vectorc::gsl_vector_int_stride_get; | ||
| 634 | *swig_stride_set = *Math::GSL::Vectorc::gsl_vector_int_stride_set; | ||
| 635 | *swig_data_get = *Math::GSL::Vectorc::gsl_vector_int_data_get; | ||
| 636 | *swig_data_set = *Math::GSL::Vectorc::gsl_vector_int_data_set; | ||
| 637 | *swig_block_get = *Math::GSL::Vectorc::gsl_vector_int_block_get; | ||
| 638 | *swig_block_set = *Math::GSL::Vectorc::gsl_vector_int_block_set; | ||
| 639 | *swig_owner_get = *Math::GSL::Vectorc::gsl_vector_int_owner_get; | ||
| 640 | *swig_owner_set = *Math::GSL::Vectorc::gsl_vector_int_owner_set; | ||
| 641 | sub new { | ||
| 642 | my $pkg = shift; | ||
| 643 | my $self = Math::GSL::Vectorc::new_gsl_vector_int(@_); | ||
| 644 | bless $self, $pkg if defined($self); | ||
| 645 | } | ||
| 646 | |||
| 647 | sub DESTROY { | ||
| 648 | return unless $_[0]->isa('HASH'); | ||
| 649 | my $self = tied(%{$_[0]}); | ||
| 650 | return unless defined $self; | ||
| 651 | delete $ITERATORS{$self}; | ||
| 652 | if (exists $OWNER{$self}) { | ||
| 653 | Math::GSL::Vectorc::delete_gsl_vector_int($self); | ||
| 654 | delete $OWNER{$self}; | ||
| 655 | } | ||
| 656 | } | ||
| 657 | |||
| 658 | sub DISOWN { | ||
| 659 | my $self = shift; | ||
| 660 | my $ptr = tied(%$self); | ||
| 661 | delete $OWNER{$ptr}; | ||
| 662 | } | ||
| 663 | |||
| 664 | sub ACQUIRE { | ||
| 665 | my $self = shift; | ||
| 666 | my $ptr = tied(%$self); | ||
| 667 | $OWNER{$ptr} = 1; | ||
| 668 | } | ||
| 669 | |||
| 670 | |||
| 671 | ############# Class : Math::GSL::Vector::_gsl_vector_int_view ############## | ||
| 672 | |||
| 673 | package Math::GSL::Vector::_gsl_vector_int_view; | ||
| 674 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 675 | @ISA = qw( Math::GSL::Vector ); | ||
| 676 | %OWNER = (); | ||
| 677 | %ITERATORS = (); | ||
| 678 | *swig_vector_get = *Math::GSL::Vectorc::_gsl_vector_int_view_vector_get; | ||
| 679 | *swig_vector_set = *Math::GSL::Vectorc::_gsl_vector_int_view_vector_set; | ||
| 680 | sub new { | ||
| 681 | my $pkg = shift; | ||
| 682 | my $self = Math::GSL::Vectorc::new__gsl_vector_int_view(@_); | ||
| 683 | bless $self, $pkg if defined($self); | ||
| 684 | } | ||
| 685 | |||
| 686 | sub DESTROY { | ||
| 687 | return unless $_[0]->isa('HASH'); | ||
| 688 | my $self = tied(%{$_[0]}); | ||
| 689 | return unless defined $self; | ||
| 690 | delete $ITERATORS{$self}; | ||
| 691 | if (exists $OWNER{$self}) { | ||
| 692 | Math::GSL::Vectorc::delete__gsl_vector_int_view($self); | ||
| 693 | delete $OWNER{$self}; | ||
| 694 | } | ||
| 695 | } | ||
| 696 | |||
| 697 | sub DISOWN { | ||
| 698 | my $self = shift; | ||
| 699 | my $ptr = tied(%$self); | ||
| 700 | delete $OWNER{$ptr}; | ||
| 701 | } | ||
| 702 | |||
| 703 | sub ACQUIRE { | ||
| 704 | my $self = shift; | ||
| 705 | my $ptr = tied(%$self); | ||
| 706 | $OWNER{$ptr} = 1; | ||
| 707 | } | ||
| 708 | |||
| 709 | |||
| 710 | ############# Class : Math::GSL::Vector::_gsl_vector_int_const_view ############## | ||
| 711 | |||
| 712 | package Math::GSL::Vector::_gsl_vector_int_const_view; | ||
| 713 | use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); | ||
| 714 | @ISA = qw( Math::GSL::Vector ); | ||
| 715 | %OWNER = (); | ||
| 716 | %ITERATORS = (); | ||
| 717 | *swig_vector_get = *Math::GSL::Vectorc::_gsl_vector_int_const_view_vector_get; | ||
| 718 | *swig_vector_set = *Math::GSL::Vectorc::_gsl_vector_int_const_view_vector_set; | ||
| 719 | sub new { | ||
| 720 | my $pkg = shift; | ||
| 721 | my $self = Math::GSL::Vectorc::new__gsl_vector_int_const_view(@_); | ||
| 722 | bless $self, $pkg if defined($self); | ||
| 723 | } | ||
| 724 | |||
| 725 | sub DESTROY { | ||
| 726 | return unless $_[0]->isa('HASH'); | ||
| 727 | my $self = tied(%{$_[0]}); | ||
| 728 | return unless defined $self; | ||
| 729 | delete $ITERATORS{$self}; | ||
| 730 | if (exists $OWNER{$self}) { | ||
| 731 | Math::GSL::Vectorc::delete__gsl_vector_int_const_view($self); | ||
| 732 | delete $OWNER{$self}; | ||
| 733 | } | ||
| 734 | } | ||
| 735 | |||
| 736 | sub DISOWN { | ||
| 737 | my $self = shift; | ||
| 738 | my $ptr = tied(%$self); | ||
| 739 | delete $OWNER{$ptr}; | ||
| 740 | } | ||
| 741 | |||
| 742 | sub ACQUIRE { | ||
| 743 | my $self = shift; | ||
| 744 | my $ptr = tied(%$self); | ||
| 745 | $OWNER{$ptr} = 1; | ||
| 746 | } | ||
| 747 | |||
| 748 | |||
| 749 | # ------- VARIABLE STUBS -------- | ||
| 750 | |||
| 751 | package Math::GSL::Vector; | ||
| 752 | |||
| 753 | *GSL_VERSION = *Math::GSL::Vectorc::GSL_VERSION; | ||
| 754 | *GSL_MAJOR_VERSION = *Math::GSL::Vectorc::GSL_MAJOR_VERSION; | ||
| 755 | *GSL_MINOR_VERSION = *Math::GSL::Vectorc::GSL_MINOR_VERSION; | ||
| 756 | *GSL_POSZERO = *Math::GSL::Vectorc::GSL_POSZERO; | ||
| 757 | *GSL_NEGZERO = *Math::GSL::Vectorc::GSL_NEGZERO; | ||
| 758 | *GSL_SUCCESS = *Math::GSL::Vectorc::GSL_SUCCESS; | ||
| 759 | *GSL_FAILURE = *Math::GSL::Vectorc::GSL_FAILURE; | ||
| 760 | *GSL_CONTINUE = *Math::GSL::Vectorc::GSL_CONTINUE; | ||
| 761 | *GSL_EDOM = *Math::GSL::Vectorc::GSL_EDOM; | ||
| 762 | *GSL_ERANGE = *Math::GSL::Vectorc::GSL_ERANGE; | ||
| 763 | *GSL_EFAULT = *Math::GSL::Vectorc::GSL_EFAULT; | ||
| 764 | *GSL_EINVAL = *Math::GSL::Vectorc::GSL_EINVAL; | ||
| 765 | *GSL_EFAILED = *Math::GSL::Vectorc::GSL_EFAILED; | ||
| 766 | *GSL_EFACTOR = *Math::GSL::Vectorc::GSL_EFACTOR; | ||
| 767 | *GSL_ESANITY = *Math::GSL::Vectorc::GSL_ESANITY; | ||
| 768 | *GSL_ENOMEM = *Math::GSL::Vectorc::GSL_ENOMEM; | ||
| 769 | *GSL_EBADFUNC = *Math::GSL::Vectorc::GSL_EBADFUNC; | ||
| 770 | *GSL_ERUNAWAY = *Math::GSL::Vectorc::GSL_ERUNAWAY; | ||
| 771 | *GSL_EMAXITER = *Math::GSL::Vectorc::GSL_EMAXITER; | ||
| 772 | *GSL_EZERODIV = *Math::GSL::Vectorc::GSL_EZERODIV; | ||
| 773 | *GSL_EBADTOL = *Math::GSL::Vectorc::GSL_EBADTOL; | ||
| 774 | *GSL_ETOL = *Math::GSL::Vectorc::GSL_ETOL; | ||
| 775 | *GSL_EUNDRFLW = *Math::GSL::Vectorc::GSL_EUNDRFLW; | ||
| 776 | *GSL_EOVRFLW = *Math::GSL::Vectorc::GSL_EOVRFLW; | ||
| 777 | *GSL_ELOSS = *Math::GSL::Vectorc::GSL_ELOSS; | ||
| 778 | *GSL_EROUND = *Math::GSL::Vectorc::GSL_EROUND; | ||
| 779 | *GSL_EBADLEN = *Math::GSL::Vectorc::GSL_EBADLEN; | ||
| 780 | *GSL_ENOTSQR = *Math::GSL::Vectorc::GSL_ENOTSQR; | ||
| 781 | *GSL_ESING = *Math::GSL::Vectorc::GSL_ESING; | ||
| 782 | *GSL_EDIVERGE = *Math::GSL::Vectorc::GSL_EDIVERGE; | ||
| 783 | *GSL_EUNSUP = *Math::GSL::Vectorc::GSL_EUNSUP; | ||
| 784 | *GSL_EUNIMPL = *Math::GSL::Vectorc::GSL_EUNIMPL; | ||
| 785 | *GSL_ECACHE = *Math::GSL::Vectorc::GSL_ECACHE; | ||
| 786 | *GSL_ETABLE = *Math::GSL::Vectorc::GSL_ETABLE; | ||
| 787 | *GSL_ENOPROG = *Math::GSL::Vectorc::GSL_ENOPROG; | ||
| 788 | *GSL_ENOPROGJ = *Math::GSL::Vectorc::GSL_ENOPROGJ; | ||
| 789 | *GSL_ETOLF = *Math::GSL::Vectorc::GSL_ETOLF; | ||
| 790 | *GSL_ETOLX = *Math::GSL::Vectorc::GSL_ETOLX; | ||
| 791 | *GSL_ETOLG = *Math::GSL::Vectorc::GSL_ETOLG; | ||
| 792 | *GSL_EOF = *Math::GSL::Vectorc::GSL_EOF; | ||
| 793 | |||
| 794 | use Scalar::Util 'blessed'; | ||
| 795 | use Data::Dumper; | ||
| 796 | use Carp qw/croak/; | ||
| 797 | use Math::GSL::Errno qw/$GSL_SUCCESS gsl_strerror/; | ||
| 798 | use Math::GSL::BLAS qw/gsl_blas_ddot/; | ||
| 799 | use Math::GSL::Test qw/is_similar/; | ||
| 800 | |||
| 801 | use overload | ||
| 802 | '*' => \&_multiplication, | ||
| 803 | '+' => \&_addition, | ||
| 804 | '-' => \&_subtract, | ||
| 805 | 'abs' => \&_abs, | ||
| 806 | '==' => \&_equal, | ||
| 807 | '!=' => \&_not_equal, | ||
| 808 | fallback => 1, | ||
| 809 | ; | ||
| 810 | |||
| 811 | @EXPORT_all = qw/fopen fclose | ||
| 812 | gsl_vector_alloc gsl_vector_calloc gsl_vector_alloc_from_block gsl_vector_alloc_from_vector | ||
| 813 | gsl_vector_free gsl_vector_view_array gsl_vector_const_view_array gsl_vector_view_array_with_stride | ||
| 814 | gsl_vector_const_view_array_with_stride gsl_vector_subvector gsl_vector_subvector_wi gsl_vector_subvector_with_stride | ||
| 815 | gsl_vector_const_subvector gsl_vector_const_subvec gsl_vector_get gsl_vector_set | ||
| 816 | gsl_vector_ptr gsl_vector_const_ptr gsl_vector_set_zero gsl_vector_set_all | ||
| 817 | gsl_vector_set_basis gsl_vector_fread gsl_vector_fwrite gsl_vector_fscanf | ||
| 818 | gsl_vector_fprintf gsl_vector_memcpy gsl_vector_reverse gsl_vector_swap | ||
| 819 | gsl_vector_swap_elements gsl_vector_max gsl_vector_min gsl_vector_minmax | ||
| 820 | gsl_vector_max_index gsl_vector_min_index gsl_vector_minmax_index | ||
| 821 | gsl_vector_add gsl_vector_sub gsl_vector_mul gsl_vector_div | ||
| 822 | gsl_vector_scale gsl_vector_add_constant gsl_vector_isnull | ||
| 823 | gsl_vector_ispos gsl_vector_isneg gsl_vector_isnonneg | ||
| 824 | gsl_vector_float_alloc gsl_vector_float_calloc gsl_vector_float_alloc_from_block | ||
| 825 | gsl_vector_float_alloc_from_vector gsl_vector_float_free gsl_vector_float_view_array | ||
| 826 | gsl_vector_float_view_array_with_stride gsl_vector_float_const_view_array gsl_vector_float_const_view_array_with_stride | ||
| 827 | gsl_vector_float_subvector gsl_vector_float_subvector_with_stride gsl_vector_float_const_subvector | ||
| 828 | gsl_vector_float_const_subvector_with_stride gsl_vector_float_get gsl_vector_float_set gsl_vector_float_ptr | ||
| 829 | gsl_vector_float_const_ptr gsl_vector_float_set_zero gsl_vector_float_set_all gsl_vector_float_set_basis | ||
| 830 | gsl_vector_float_fread gsl_vector_float_fwrite gsl_vector_float_fscanf gsl_vector_float_fprintf | ||
| 831 | gsl_vector_float_memcpy gsl_vector_float_reverse gsl_vector_float_swap gsl_vector_float_swap_elements | ||
| 832 | gsl_vector_float_max gsl_vector_float_min gsl_vector_float_minmax gsl_vector_float_max_index gsl_vector_float_min_index | ||
| 833 | gsl_vector_float_minmax_index gsl_vector_float_add gsl_vector_float_sub gsl_vector_float_mul gsl_vector_float_div gsl_vector_float_scale | ||
| 834 | gsl_vector_float_add_constant gsl_vector_float_isnull gsl_vector_float_ispos gsl_vector_float_isneg gsl_vector_float_isnonneg | ||
| 835 | /; | ||
| 836 | |||
| 837 | @EXPORT_file =qw/ fopen fclose/; | ||
| 838 | @EXPORT_OK = (@EXPORT_all, @EXPORT_file); | ||
| 839 | %EXPORT_TAGS = ( file => \@EXPORT_file, all => \@EXPORT_all ); | ||
| 840 | |||
| 841 | =encoding utf8 | ||
| 842 | |||
| 843 | =head1 NAME | ||
| 844 | |||
| 845 | Math::GSL::Vector - Functions concerning vectors | ||
| 846 | |||
| 847 | =head1 SYNOPSIS | ||
| 848 | |||
| 849 | use Math::GSL::Vector qw/:all/; | ||
| 850 | my $vec1 = Math::GSL::Vector->new([1, 7, 94, 15 ]); | ||
| 851 | my $vec2 = $vec1 * 5; | ||
| 852 | my $vec3 = Math::GSL::Vector>new(10); # 10 element zero vector | ||
| 853 | my $vec4 = $vec1 + $vec2; | ||
| 854 | |||
| 855 | # set the element at index 1 to 9 | ||
| 856 | # and the element at index 3 to 8 | ||
| 857 | $vec3->set([ 1, 3 ], [ 9, 8 ]); | ||
| 858 | |||
| 859 | my @vec = $vec2->as_list; # return elements as Perl list | ||
| 860 | |||
| 861 | my $dot_product = $vec1 * $vec2; | ||
| 862 | my $length = $vec2->length; | ||
| 863 | my $first = $vec1->get(0); | ||
| 864 | |||
| 865 | # access raw GSL object to call low-level functions | ||
| 866 | my $raw = $vec1->raw; | ||
| 867 | my $element = gsl_vector_get($raw, 2); | ||
| 868 | |||
| 869 | =cut | ||
| 870 | |||
| 871 | =head1 Objected Oriented Interface to GSL Math::GSL::Vector | ||
| 872 | |||
| 873 | =head2 Math::GSL::Vector->new() | ||
| 874 | |||
| 875 | Creates a new Vector of the given size. | ||
| 876 | |||
| 877 | my $vector = Math::GSL::Vector->new(3); | ||
| 878 | |||
| 879 | You can also create and set directly the values of the vector like this : | ||
| 880 | |||
| 881 | my $vector = Math::GSL::Vector->new([2,4,1]); | ||
| 882 | |||
| 883 | =cut | ||
| 884 | |||
| 885 | sub new { | ||
| 886 | my ($class, $values) = @_; | ||
| 887 | my $length = $#$values; | ||
| 888 | my $this = {}; | ||
| 889 | my $vector; | ||
| 890 | if ( ref $values eq 'ARRAY' ){ | ||
| 891 | die __PACKAGE__.'::new($x) - $x must be a nonempty array reference' if $length == -1; | ||
| 892 | $vector = gsl_vector_alloc($length+1); | ||
| 893 | map { gsl_vector_set($vector, $_, $values->[$_] ) } (0 .. $length); | ||
| 894 | $this->{_length} = $length+1; | ||
| 895 | } elsif ( (int($values) == $values) && ($values > 0)) { | ||
| 896 | $vector = gsl_vector_alloc($values); | ||
| 897 | gsl_vector_set_zero($vector); | ||
| 898 | $this->{_length} = $values; | ||
| 899 | } else { | ||
| 900 | die __PACKAGE__.'::new($x) - $x must be an int or array reference'; | ||
| 901 | } | ||
| 902 | $this->{_vector} = $vector; | ||
| 903 | bless $this, $class; | ||
| 904 | } | ||
| 905 | =head2 raw() | ||
| 906 | |||
| 907 | Get the underlying GSL vector object created by SWIG, useful for using gsl_vector_* functions which do not have an OO counterpart. | ||
| 908 | |||
| 909 | my $vector = Math::GSL::Vector->new(3); | ||
| 910 | my $gsl_vector = $vector->raw; | ||
| 911 | my $stuff = gsl_vector_get($gsl_vector, 1); | ||
| 912 | |||
| 913 | =cut | ||
| 914 | |||
| 915 | sub raw { | ||
| 916 | my $self = shift; | ||
| 917 | return $self->{_vector}; | ||
| 918 | } | ||
| 919 | |||
| 920 | =head2 swap() | ||
| 921 | |||
| 922 | Exchanges the values in the vectors $v with $w by copying. | ||
| 923 | |||
| 924 | my $v = Math::GSL::Vector->new([1..5]); | ||
| 925 | my $w = Math::GSL::Vector->new([3..7]); | ||
| 926 | $v->swap( $w ); | ||
| 927 | |||
| 928 | =cut | ||
| 929 | |||
| 930 | sub swap() { | ||
| 931 | my ($self,$other) = @_; | ||
| 932 | croak "Math::GSL::Vector: \$v->swap(\$w) : \$w must be a Math::GSL::Vector" | ||
| 933 | unless ref $other eq 'Math::GSL::Vector'; | ||
| 934 | gsl_vector_swap( $self->raw, $other->raw ); | ||
| 935 | return $self; | ||
| 936 | } | ||
| 937 | |||
| 938 | =head2 reverse() | ||
| 939 | |||
| 940 | Reverse the elements in the vector. | ||
| 941 | |||
| 942 | $v->reverse; | ||
| 943 | |||
| 944 | =cut | ||
| 945 | |||
| 946 | sub reverse() { | ||
| 947 | my $self = shift; | ||
| 948 | gsl_vector_reverse($self->raw); | ||
| 949 | return $self; | ||
| 950 | } | ||
| 951 | |||
| 952 | =head2 min() | ||
| 953 | |||
| 954 | Returns the minimum value contained in the vector. | ||
| 955 | |||
| 956 | my $vector = Math::GSL::Vector->new([2,4,1]); | ||
| 957 | my $minimum = $vector->min; | ||
| 958 | |||
| 959 | =cut | ||
| 960 | |||
| 961 | sub min { | ||
| 962 | my $self=shift; | ||
| 963 | return gsl_vector_min($self->raw); | ||
| 964 | } | ||
| 965 | |||
| 966 | =head2 max() | ||
| 967 | |||
| 968 | Returns the minimum value contained in the vector. | ||
| 969 | |||
| 970 | my $vector = Math::GSL::Vector->new([2,4,1]); | ||
| 971 | my $maximum = $vector->max; | ||
| 972 | |||
| 973 | =cut | ||
| 974 | |||
| 975 | sub max { | ||
| 976 | my $self=shift; | ||
| 977 | return gsl_vector_max($self->raw); | ||
| 978 | } | ||
| 979 | |||
| 980 | =head2 length() | ||
| 981 | |||
| 982 | Returns the number of elements contained in the vector. | ||
| 983 | |||
| 984 | my $vector = Math::GSL::Vector->new([2,4,1]); | ||
| 985 | my $length = $vector->length; | ||
| 986 | |||
| 987 | =cut | ||
| 988 | |||
| 989 | sub length { my $self=shift; $self->{_length} } | ||
| 990 | |||
| 991 | =head2 $v->norm($p) | ||
| 992 | |||
| 993 | Returns the p-norm of $v, which defaults to the Euclidean (p=2) norm when no argument is given. | ||
| 994 | |||
| 995 | my $euclidean_distance = $v->norm; | ||
| 996 | |||
| 997 | =cut | ||
| 998 | |||
| 999 | sub norm($;$) | ||
| 1000 | { | ||
| 1001 | my ($self,$p) = @_; | ||
| 1002 | my $norm = 0; | ||
| 1003 | $p ||= 2; | ||
| 1004 | |||
| 1005 | map { $norm += $p == 1 ? abs $_ : $_ ** $p } ($self->as_list); | ||
| 1006 | return $norm ** (1 / $p); | ||
| 1007 | } | ||
| 1008 | |||
| 1009 | =head2 normalize($p) | ||
| 1010 | |||
| 1011 | Divide each element of a vector by its norm, hence creating a unit vector. | ||
| 1012 | Returns the vector for chaining. If you just want the value of the norm | ||
| 1013 | without changing the vector, use C<norm()>. The default value for C<$p> is 2, | ||
| 1014 | which gives the familiar Euclidean distance norm. | ||
| 1015 | |||
| 1016 | my $unit_vector = $vector->normalize(2); | ||
| 1017 | |||
| 1018 | is the same as | ||
| 1019 | |||
| 1020 | my $unit_vector = $vector->normalize; | ||
| 1021 | |||
| 1022 | =cut | ||
| 1023 | |||
| 1024 | sub normalize($;$) | ||
| 1025 | { | ||
| 1026 | my ($self,$p) = @_; | ||
| 1027 | $p ||= 2; | ||
| 1028 | my $norm = $self->norm($p); | ||
| 1029 | return $self if ($norm == 0); | ||
| 1030 | |||
| 1031 | my $status = gsl_vector_scale( $self->raw, 1/$norm ); | ||
| 1032 | croak "Math::GSL::Vector - could not scale vectr" unless $status == $GSL_SUCCESS; | ||
| 1033 | return $self; | ||
| 1034 | } | ||
| 1035 | |||
| 1036 | =head2 as_list() | ||
| 1037 | |||
| 1038 | Gets the content of a Math::GSL::Vector object as a Perl list. | ||
| 1039 | |||
| 1040 | my $vector = Math::GSL::Vector->new(3); | ||
| 1041 | ... | ||
| 1042 | my @values = $vector->as_list; | ||
| 1043 | |||
| 1044 | =cut | ||
| 1045 | |||
| 1046 | sub as_list { | ||
| 1047 | my $self=shift; | ||
| 1048 | $self->get( [ 0 .. $self->length - 1 ] ); | ||
| 1049 | } | ||
| 1050 | |||
| 1051 | =head2 get() | ||
| 1052 | |||
| 1053 | Gets the value of an of a Math::GSL::Vector object. | ||
| 1054 | |||
| 1055 | my $vector = Math::GSL::Vector->new(3); | ||
| 1056 | ... | ||
| 1057 | my @values = $vector->get(2); | ||
| 1058 | |||
| 1059 | You can also enter an array of indices to receive their corresponding values: | ||
| 1060 | |||
| 1061 | my $vector = Math::GSL::Vector->new(3); | ||
| 1062 | ... | ||
| 1063 | my @values = $vector->get([0,2]); | ||
| 1064 | |||
| 1065 | =cut | ||
| 1066 | |||
| 1067 | sub get { | ||
| 1068 | my ($self, $indices) = @_; | ||
| 1069 | |||
| 1070 | return gsl_vector_get($self->raw, $indices) unless ref $indices; | ||
| 1071 | |||
| 1072 | return map { gsl_vector_get($self->raw, $_ ) } @$indices ; | ||
| 1073 | } | ||
| 1074 | |||
| 1075 | =head2 set() | ||
| 1076 | |||
| 1077 | Sets values of an of a Math::GSL::Vector object. | ||
| 1078 | |||
| 1079 | my $vector = Math::GSL::Vector->new(3); | ||
| 1080 | $vector->set([1,2], [8,23]); | ||
| 1081 | |||
| 1082 | This sets the second and third value to 8 and 23. | ||
| 1083 | |||
| 1084 | =cut | ||
| 1085 | |||
| 1086 | sub set { | ||
| 1087 | my ($self, $indices, $values) = @_; | ||
| 1088 | die (__PACKAGE__.'::set($indices, $values) - $indices and $values must be array references of the same length') | ||
| 1089 | unless ( ref $indices eq 'ARRAY' && ref $values eq 'ARRAY' && $#$indices == $#$values ); | ||
| 1090 | eval { | ||
| 1091 | map { gsl_vector_set($self->{_vector}, $indices->[$_], $values->[$_] ) } (0..$#$indices); | ||
| 1092 | }; | ||
| 1093 | return; | ||
| 1094 | } | ||
| 1095 | |||
| 1096 | =head2 copy() | ||
| 1097 | |||
| 1098 | Returns a copy of the vector, which has the same length and values but resides at a different location in memory. | ||
| 1099 | |||
| 1100 | my $vector = Math::GSL::Vector->new([10 .. 20]); | ||
| 1101 | my $copy = $vector->copy; | ||
| 1102 | |||
| 1103 | =cut | ||
| 1104 | |||
| 1105 | |||
| 1106 | sub copy { | ||
| 1107 | my $self = shift; | ||
| 1108 | my $copy = Math::GSL::Vector->new( $self->length ); | ||
| 1109 | if ( gsl_vector_memcpy($copy->raw, $self->raw) != $GSL_SUCCESS ) { | ||
| 1110 | croak "Math::GSL - error copying memory, aborting"; | ||
| 1111 | } | ||
| 1112 | return $copy; | ||
| 1113 | } | ||
| 1114 | |||
| 1115 | sub _multiplication { | ||
| 1116 | my ($left,$right) = @_; | ||
| 1117 | my $lcopy = $left->copy; | ||
| 1118 | |||
| 1119 | if ( blessed $right && $right->isa('Math::GSL::Vector') ) { | ||
| 1120 | return $lcopy->dot_product($right); | ||
| 1121 | } else { | ||
| 1122 | gsl_vector_scale($lcopy->raw, $right); | ||
| 1123 | } | ||
| 1124 | return $lcopy; | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | sub _subtract { | ||
| 1128 | my ($left, $right, $flip) = @_; | ||
| 1129 | |||
| 1130 | if ($flip) { | ||
| 1131 | my $lcopy = $left->copy; | ||
| 1132 | gsl_vector_scale($lcopy->raw, -1 ); | ||
| 1133 | gsl_vector_add_constant($lcopy->raw, $right); | ||
| 1134 | return $lcopy; | ||
| 1135 | } else { | ||
| 1136 | return _addition($left, -1.0*$right); | ||
| 1137 | } | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | sub _abs { | ||
| 1141 | my $self = shift; | ||
| 1142 | $self->norm; | ||
| 1143 | } | ||
| 1144 | |||
| 1145 | sub _addition { | ||
| 1146 | my ($left, $right, $flip) = @_; | ||
| 1147 | |||
| 1148 | my $lcopy = $left->copy; | ||
| 1149 | |||
| 1150 | if ( blessed $right && $right->isa('Math::GSL::Vector') && blessed $left && $left->isa('Math::GSL::Vector') ) { | ||
| 1151 | if ( $left->length == $right->length ) { | ||
| 1152 | gsl_vector_add($lcopy->raw, $right->raw); | ||
| 1153 | } else { | ||
| 1154 | croak "Math::GSL - addition of vectors must be called with two objects vectors and must have the same length"; | ||
| 1155 | } | ||
| 1156 | } else { | ||
| 1157 | gsl_vector_add_constant($lcopy->raw, $right); | ||
| 1158 | } | ||
| 1159 | return $lcopy; | ||
| 1160 | } | ||
| 1161 | |||
| 1162 | sub dot_product_pp { | ||
| 1163 | my ($left,$right) = @_; | ||
| 1164 | my $sum=0; | ||
| 1165 | if ( blessed $right && $right->isa('Math::GSL::Vector') && | ||
| 1166 | $left->length == $right->length ) { | ||
| 1167 | my @l = $left->as_list; | ||
| 1168 | my @r = $right->as_list; | ||
| 1169 | map { $sum += $l[$_] * $r[$_] } (0..$#l); | ||
| 1170 | return $sum; | ||
| 1171 | } else { | ||
| 1172 | croak "dot_product() must be called with two vectors"; | ||
| 1173 | } | ||
| 1174 | } | ||
| 1175 | |||
| 1176 | sub dot_product { | ||
| 1177 | my ($left,$right) = @_; | ||
| 1178 | |||
| 1179 | my ($status, $product) = gsl_blas_ddot($left->raw,$right->raw); | ||
| 1180 | croak sprintf "Math::GSL::dot_product - %s", gsl_strerror($status) if ($status != $GSL_SUCCESS); | ||
| 1181 | return $product; | ||
| 1182 | } | ||
| 1183 | |||
| 1184 | sub _equal { | ||
| 1185 | my ($left,$right) = @_; | ||
| 1186 | |||
| 1187 | return 0 if ($left->length != $right->length); | ||
| 1188 | |||
| 1189 | return is_similar( [$left->as_list ], [$right->as_list ]); | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | sub _not_equal { | ||
| 1193 | my ($left, $right) = @_; | ||
| 1194 | return !_equal($left,$right); | ||
| 1195 | } | ||
| 1196 | |||
| 1197 | =head1 DESCRIPTION | ||
| 1198 | |||
| 1199 | Here is a list of all the functions included in this module : | ||
| 1200 | |||
| 1201 | =over 1 | ||
| 1202 | |||
| 1203 | =item C<gsl_vector_alloc($x)> | ||
| 1204 | |||
| 1205 | Create a vector of size $x | ||
| 1206 | |||
| 1207 | =item C<gsl_vector_calloc($x)> | ||
| 1208 | |||
| 1209 | Create a vector of size $x and initializes all the elements of the vector to zero | ||
| 1210 | |||
| 1211 | =item C<gsl_vector_alloc_from_block> | ||
| 1212 | |||
| 1213 | =item C<gsl_vector_alloc_from_vector> | ||
| 1214 | |||
| 1215 | =item C<gsl_vector_free($v)> | ||
| 1216 | |||
| 1217 | Free a previously allocated vector $v | ||
| 1218 | |||
| 1219 | =item C<gsl_vector_view_array($base, $n)> | ||
| 1220 | |||
| 1221 | This function returns a vector view of an array reference $base. The start of | ||
| 1222 | the new vector is given by $base and has $n elements. Mathematically, the i-th | ||
| 1223 | element of the new vector v' is given by, v'(i) = $base->[i] where the index i | ||
| 1224 | runs from 0 to $n-1. The array containing the elements of v is not owned by the | ||
| 1225 | new vector view. When the view goes out of scope the original array will | ||
| 1226 | continue to exist. The original memory can only be deallocated by freeing the | ||
| 1227 | original pointer base. Of course, the original array should not be deallocated | ||
| 1228 | while the view is still in use. | ||
| 1229 | |||
| 1230 | =item C<gsl_vector_const_view_array($base, $n)> | ||
| 1231 | |||
| 1232 | This function is equivalent to gsl_vector_view_array but can be used for arrays which are declared const. | ||
| 1233 | |||
| 1234 | =item C<gsl_vector_view_array_with_stride($base, $stride, $n)> | ||
| 1235 | |||
| 1236 | This function returns a vector view of an array reference $base with an | ||
| 1237 | additional $stride argument. The subvector is formed in the same way as for | ||
| 1238 | gsl_vector_view_array but the new vector has $n elements with a step-size of | ||
| 1239 | $stride from one element to the next in the original array. Mathematically, | ||
| 1240 | the i-th element of the new vector v' is given by, v'(i) = $base->[i*$stride] | ||
| 1241 | where the index i runs from 0 to $n-1. Note that the view gives direct access | ||
| 1242 | to the underlying elements of the original array. A vector view $view can be | ||
| 1243 | passed to any subroutine which takes a vector argument just as a directly | ||
| 1244 | allocated vector would be, using $view->{vector}. | ||
| 1245 | |||
| 1246 | =item C<gsl_vector_const_view_array_with_stride($base, $stride, $n)> | ||
| 1247 | |||
| 1248 | This function is equivalent to gsl_vector_view_array_with_stride but can be | ||
| 1249 | used for arrays which are declared const. | ||
| 1250 | |||
| 1251 | =item C<gsl_vector_subvector($v, $offset, $n)> | ||
| 1252 | |||
| 1253 | Return a vector_view type which contains a subvector of $v, with a size of $size, starting from the $offset position | ||
| 1254 | |||
| 1255 | =item C<gsl_vector_subvector_with_stride($v, $offset, $stride, $size)> | ||
| 1256 | |||
| 1257 | Return a vector_view type which contains a subvector of $v, with a size of | ||
| 1258 | $size, starting from the $offset position and with a $stride step between each | ||
| 1259 | element of $v | ||
| 1260 | |||
| 1261 | =item C<gsl_vector_const_subvector> | ||
| 1262 | |||
| 1263 | |||
| 1264 | =item C<gsl_vector_get($v, $i)> | ||
| 1265 | |||
| 1266 | Return the $i-th element of a raw vector $v, where $v is a Math::GSL::Vector object. For example: | ||
| 1267 | |||
| 1268 | my $third_element = gsl_vector_get($v->raw, 3); | ||
| 1269 | |||
| 1270 | =item C<gsl_vector_set($v, $i, $x)> | ||
| 1271 | |||
| 1272 | Return the vector $v with his $i-th element set to $x | ||
| 1273 | |||
| 1274 | =item C<gsl_vector_ptr> | ||
| 1275 | |||
| 1276 | =item C<gsl_vector_const_ptr> | ||
| 1277 | |||
| 1278 | =item C<gsl_vector_set_zero($v)> | ||
| 1279 | |||
| 1280 | set all the elements of $v to 0 | ||
| 1281 | |||
| 1282 | =item C<gsl_vector_set_all($v, $x)> | ||
| 1283 | |||
| 1284 | set all the elements of $v to $x | ||
| 1285 | |||
| 1286 | =item C<gsl_vector_set_basis($v, $i)> | ||
| 1287 | |||
| 1288 | set all the elements of $v to 0 except for the $i-th element which is set to 1 | ||
| 1289 | and return 0 if the operation succeded, 1 otherwise. | ||
| 1290 | |||
| 1291 | =item C<gsl_vector_fread($file, $v)> | ||
| 1292 | |||
| 1293 | This function reads into the vector $v from the open stream $file opened with | ||
| 1294 | gsl_fopen function from the Math::GSL module in binary format. The vector $v | ||
| 1295 | must be preallocated with the correct length since the function uses the size | ||
| 1296 | of $v to determine how many bytes to read. The return value is 0 for success | ||
| 1297 | and 1 if there was a problem reading from the file. | ||
| 1298 | |||
| 1299 | =item C<gsl_vector_fwrite($file, $v)> | ||
| 1300 | |||
| 1301 | This function writes the elements of the vector $v to the stream $file opened | ||
| 1302 | with gsl_fopen function from the Math::GSL module in binary format. The return | ||
| 1303 | value is 0 for success and 1 if there was a problem writing to the file. Since | ||
| 1304 | the data is written in the native binary format it may not be portable between | ||
| 1305 | different architectures. | ||
| 1306 | |||
| 1307 | =item C<gsl_vector_fscanf($file, $v)> | ||
| 1308 | |||
| 1309 | This function reads formatted data from the stream $file opened with gsl_fopen | ||
| 1310 | function from the Math::GSL module into the vector $v. The vector $v must be | ||
| 1311 | preallocated with the correct length since the function uses the size of $v to | ||
| 1312 | determine how many numbers to read. The function returns 0 for success and 1 if | ||
| 1313 | there was a problem reading from the file. | ||
| 1314 | |||
| 1315 | =item C<gsl_vector_fprintf($file, $v, $format)> | ||
| 1316 | |||
| 1317 | This function writes the elements of the vector $v line-by-line to the stream | ||
| 1318 | $file opened with gsl_fopen function from the Math::GSL module using the format | ||
| 1319 | specifier $format, which should be one of the "%g", "%e" or "%f" formats for | ||
| 1320 | floating point numbers and "%d" for integers. The function returns 0 for | ||
| 1321 | success and 1 if there was a problem writing to the file. | ||
| 1322 | |||
| 1323 | =item C<gsl_vector_memcpy($dest, $src)> | ||
| 1324 | |||
| 1325 | This function copies the elements of the vector $src into the vector $dest and | ||
| 1326 | return 0 if the opertaion succeded, 1 otherwise. The two vectors must have the | ||
| 1327 | same length. | ||
| 1328 | |||
| 1329 | =item C<gsl_vector_reverse($v)> | ||
| 1330 | |||
| 1331 | reverse the order of the elements of the vector $v and return 0 if the | ||
| 1332 | opertaion succeded, 1 otherwise | ||
| 1333 | |||
| 1334 | =item C<gsl_vector_swap($v, $v2)> | ||
| 1335 | |||
| 1336 | swap the values of the vectors $v and $v2 and return 0 if the opertaion | ||
| 1337 | succeded, 1 otherwise | ||
| 1338 | |||
| 1339 | =item C<gsl_vector_swap_elements($v, $i, $j)> | ||
| 1340 | |||
| 1341 | permute the elements at position $i and $j in the vector $v and return 0 if the | ||
| 1342 | operation succeded, 1 otherwise. | ||
| 1343 | |||
| 1344 | =item C<gsl_vector_max($v)> | ||
| 1345 | |||
| 1346 | return the maximum value in the vector $v | ||
| 1347 | |||
| 1348 | =item C<gsl_vector_min($v)> | ||
| 1349 | |||
| 1350 | return the minimum value in the vector $v | ||
| 1351 | |||
| 1352 | =item C<gsl_vector_minmax($v)> | ||
| 1353 | |||
| 1354 | return two values, the first is the minimum value in the vector $v and the | ||
| 1355 | second is the maximum value. | ||
| 1356 | |||
| 1357 | =item C<gsl_vector_max_index($v)> | ||
| 1358 | |||
| 1359 | return the position of the maximum value in the vector $v | ||
| 1360 | |||
| 1361 | =item C<gsl_vector_min_index($v)> | ||
| 1362 | |||
| 1363 | return the position of the minimum value in the vector $v | ||
| 1364 | |||
| 1365 | =item C<gsl_vector_minmax_index> | ||
| 1366 | |||
| 1367 | return two values, the first is the position of the minimum value in the vector | ||
| 1368 | $v and the second is the position of the maximum value. | ||
| 1369 | |||
| 1370 | =item C<gsl_vector_add($v, $v2)> | ||
| 1371 | |||
| 1372 | add the elements of $v2 to the elements of $v, the two vectors must have the | ||
| 1373 | same length and return 0 if the operation succeded, 1 otherwise. | ||
| 1374 | |||
| 1375 | =item C<gsl_vector_sub($v, $v2)> | ||
| 1376 | |||
| 1377 | substract the elements of $v2 from the elements of $v, the two vectors must | ||
| 1378 | have the same length and return 0 if the operation succeded, 1 otherwise. | ||
| 1379 | |||
| 1380 | =item C<gsl_vector_mul($v, $v2)> | ||
| 1381 | |||
| 1382 | multiply the elements of $v by the elements of $v2, the two vectors must have | ||
| 1383 | the same length and return 0 if the operation succeded, 1 otherwise. | ||
| 1384 | |||
| 1385 | =item C<gsl_vector_div($v, $v2)> | ||
| 1386 | |||
| 1387 | divides the elements of $v by the elements of $v2, the two vectors must have | ||
| 1388 | the same length and return 0 if the operation succeded, 1 otherwise. | ||
| 1389 | |||
| 1390 | =item C<gsl_vector_scale($v, $x)> | ||
| 1391 | |||
| 1392 | multiplty the elements of the vector $v by a constant $x and return 0 if the | ||
| 1393 | operation succeded, 1 otherwise. | ||
| 1394 | |||
| 1395 | =item C<gsl_vector_add_constant($v, $x)> | ||
| 1396 | |||
| 1397 | add a constant $x to the elements of the vector $v and return 0 if the | ||
| 1398 | operation succeded, 1 otherwise. | ||
| 1399 | |||
| 1400 | =item C<gsl_vector_isnull($v)> | ||
| 1401 | |||
| 1402 | verify if all the elements of the vector $v are null, return 0 if it's the | ||
| 1403 | case, 1 otherwise. | ||
| 1404 | |||
| 1405 | =item C<gsl_vector_ispos($v)> | ||
| 1406 | |||
| 1407 | verify if all the elements of the vector $v are positive, return 0 if it's the | ||
| 1408 | case, 1 otherwise. | ||
| 1409 | |||
| 1410 | =item C<gsl_vector_isneg($v)> | ||
| 1411 | |||
| 1412 | verify if all the elements of the vector $v are negative, return 0 if it's the | ||
| 1413 | case, 1 otherwise. | ||
| 1414 | |||
| 1415 | =item C<gsl_vector_isnonneg($v)> | ||
| 1416 | |||
| 1417 | verify if all the elements the vector $v are not negative, return 0 if it's the | ||
| 1418 | case, 1 otherwise. | ||
| 1419 | |||
| 1420 | =back | ||
| 1421 | |||
| 1422 | Precision on the vector_view type : every modification you'll make on a | ||
| 1423 | vector_view will also modify the original vector. For example, the following | ||
| 1424 | code will zero the even elements of the vector $v of length $size, while | ||
| 1425 | leaving the odd elements untouched : | ||
| 1426 | |||
| 1427 | =over 1 | ||
| 1428 | |||
| 1429 | =item C<$v_even= gsl_vector_subvector_with_stride ($v, 0, 2, $size/2);> | ||
| 1430 | |||
| 1431 | =item C<gsl_vector_set_zero ($v_even-E<gt>{vector});> | ||
| 1432 | |||
| 1433 | =back | ||
| 1434 | |||
| 1435 | For more informations on the functions, we refer you to the GSL official documentation: | ||
| 1436 | L<http://www.gnu.org/software/gsl/manual/html_node/> | ||
| 1437 | |||
| 1438 | =head1 EXAMPLES | ||
| 1439 | |||
| 1440 | Here is an example using both interfaces. | ||
| 1441 | |||
| 1442 | use Math::GSL::Vector qw/:all/; | ||
| 1443 | |||
| 1444 | print "We'll create this vector : [0,1,4,9,16] \n"; | ||
| 1445 | my $vector = Math::GSL::Vector->new([0,1,4,9,16]); | ||
| 1446 | my ($min, $max) = gsl_vector_minmax_index($vector->raw); | ||
| 1447 | |||
| 1448 | print "We then check the index value of the maximum and minimum values of the vector. \n"; | ||
| 1449 | print "The index of the maximum should be 4 and we received $max \n"; | ||
| 1450 | print "The index of the minimum should be 0 and we received $min \n"; | ||
| 1451 | print "We'll then swap the first and the third elements of the vector \n"; | ||
| 1452 | |||
| 1453 | gsl_vector_swap_elements($vector->raw, 0, 3); | ||
| 1454 | my @got = $vector->as_list; | ||
| 1455 | print "The vector should now be like this : [9,1,4,0,16] \n"; | ||
| 1456 | print "and we received : [ @got ]\n"; | ||
| 1457 | |||
| 1458 | =head1 AUTHORS | ||
| 1459 | |||
| 1460 | Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com> | ||
| 1461 | |||
| 1462 | =head1 COPYRIGHT AND LICENSE | ||
| 1463 | |||
| 1464 | Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan | ||
| 1465 | |||
| 1466 | This program is free software; you can redistribute it and/or modify it | ||
| 1467 | under the same terms as Perl itself. | ||
| 1468 | |||
| 1469 | =cut | ||
| 1470 | 1; |