| 1 | /* vector/subvector_source.c |
| 2 | * |
| 3 | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | QUALIFIED_VIEWcxx . . $ `./templates_on.h:212:9`!(_gsl_vector, view) |
| 21 | FUNCTIONcxx . . $ `./templates_on.h:208:9`!(gsl_vector, subvector) (QUALIFIED_TYPEcxx . . $ `./templates_on.h:211:9`!(gsl_vector) * v, size_t offset, size_t n) |
| 22 | { |
| 23 | QUALIFIED_VIEWcxx . . $ `./templates_on.h:212:9`!(_gsl_vector,view) view = NULL_VECTOR_VIEWcxx . . $ `external/gsl/gsl_vector__view.h:2:9`!; |
| 24 | |
| 25 | if (n == 0) |
| 26 | { |
| 27 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("vector length n must be positive integer", |
| 28 | GSL_EINVAL, view); |
| 29 | } |
| 30 | |
| 31 | if (offset + (n - 1) >= v->sizecxx . . $ $anonymous_type_4aae4d8517eb1558_0#size.) |
| 32 | { |
| 33 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("view would extend past end of vector", |
| 34 | GSL_EINVAL, view); |
| 35 | } |
| 36 | |
| 37 | { |
| 38 | TYPEcxx . . $ `./templates_on.h:209:9`!(gsl_vector) s = NULL_VECTORcxx . . $ `external/gsl/gsl_vector__view.h:1:9`!; |
| 39 | |
| 40 | s.datacxx . . $ $anonymous_type_4aae4d8517eb1558_0#data. = v->datacxx . . $ $anonymous_type_4aae4d8517eb1558_0#data. + MULTIPLICITYcxx . . $ `./templates_on.h:106:9`! * v->stridecxx . . $ $anonymous_type_4aae4d8517eb1558_0#stride. * offset ; |
| 41 | s.sizecxx . . $ $anonymous_type_4aae4d8517eb1558_0#size. = n; |
| 42 | s.stridecxx . . $ $anonymous_type_4aae4d8517eb1558_0#stride. = v->stridecxx . . $ $anonymous_type_4aae4d8517eb1558_0#stride.; |
| 43 | s.blockcxx . . $ $anonymous_type_4aae4d8517eb1558_0#block. = v->blockcxx . . $ $anonymous_type_4aae4d8517eb1558_0#block.; |
| 44 | s.ownercxx . . $ $anonymous_type_4aae4d8517eb1558_0#owner. = 0; |
| 45 | |
| 46 | view.vectorcxx . . $ $anonymous_type_4aae4d8517eb1558_2#vector. = s; |
| 47 | return view; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | QUALIFIED_VIEWcxx . . $ `./templates_on.h:212:9`!(_gsl_vector, view) |
| 52 | FUNCTIONcxx . . $ `./templates_on.h:208:9`!(gsl_vector, subvector_with_stride) (QUALIFIED_TYPEcxx . . $ `./templates_on.h:211:9`!(gsl_vector) * v, size_t offset, size_t stride, size_t n) |
| 53 | { |
| 54 | QUALIFIED_VIEWcxx . . $ `./templates_on.h:212:9`!(_gsl_vector,view) view = NULL_VECTOR_VIEWcxx . . $ `external/gsl/gsl_vector__view.h:2:9`!; |
| 55 | |
| 56 | if (n == 0) |
| 57 | { |
| 58 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("vector length n must be positive integer", |
| 59 | GSL_EINVAL, view); |
| 60 | } |
| 61 | |
| 62 | if (stride == 0) |
| 63 | { |
| 64 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("stride must be positive integer", |
| 65 | GSL_EINVAL, view); |
| 66 | } |
| 67 | |
| 68 | if (offset + (n - 1) * stride >= v->sizecxx . . $ $anonymous_type_4aae4d8517eb1558_0#size.) |
| 69 | { |
| 70 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("view would extend past end of vector", |
| 71 | GSL_EINVAL, view); |
| 72 | } |
| 73 | |
| 74 | { |
| 75 | TYPEcxx . . $ `./templates_on.h:209:9`!(gsl_vector) s = NULL_VECTORcxx . . $ `external/gsl/gsl_vector__view.h:1:9`!; |
| 76 | |
| 77 | s.datacxx . . $ $anonymous_type_4aae4d8517eb1558_0#data. = v->datacxx . . $ $anonymous_type_4aae4d8517eb1558_0#data. + MULTIPLICITYcxx . . $ `./templates_on.h:106:9`! * v->stridecxx . . $ $anonymous_type_4aae4d8517eb1558_0#stride. * offset ; |
| 78 | s.sizecxx . . $ $anonymous_type_4aae4d8517eb1558_0#size. = n; |
| 79 | s.stridecxx . . $ $anonymous_type_4aae4d8517eb1558_0#stride. = v->stridecxx . . $ $anonymous_type_4aae4d8517eb1558_0#stride. * stride; |
| 80 | s.blockcxx . . $ $anonymous_type_4aae4d8517eb1558_0#block. = v->blockcxx . . $ $anonymous_type_4aae4d8517eb1558_0#block.; |
| 81 | s.ownercxx . . $ $anonymous_type_4aae4d8517eb1558_0#owner. = 0; |
| 82 | |
| 83 | view.vectorcxx . . $ $anonymous_type_4aae4d8517eb1558_2#vector. = s; |
| 84 | return view; |
| 85 | } |
| 86 | } |