Warning, file /include/gsl/gsl_vector_short.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef __GSL_VECTOR_SHORT_H__
0021 #define __GSL_VECTOR_SHORT_H__
0022
0023 #include <stdlib.h>
0024 #include <gsl/gsl_types.h>
0025 #include <gsl/gsl_errno.h>
0026 #include <gsl/gsl_inline.h>
0027 #include <gsl/gsl_check_range.h>
0028 #include <gsl/gsl_block_short.h>
0029
0030 #undef __BEGIN_DECLS
0031 #undef __END_DECLS
0032 #ifdef __cplusplus
0033 # define __BEGIN_DECLS extern "C" {
0034 # define __END_DECLS }
0035 #else
0036 # define __BEGIN_DECLS
0037 # define __END_DECLS
0038 #endif
0039
0040 __BEGIN_DECLS
0041
0042 typedef struct
0043 {
0044 size_t size;
0045 size_t stride;
0046 short *data;
0047 gsl_block_short *block;
0048 int owner;
0049 }
0050 gsl_vector_short;
0051
0052 typedef struct
0053 {
0054 gsl_vector_short vector;
0055 } _gsl_vector_short_view;
0056
0057 typedef _gsl_vector_short_view gsl_vector_short_view;
0058
0059 typedef struct
0060 {
0061 gsl_vector_short vector;
0062 } _gsl_vector_short_const_view;
0063
0064 typedef const _gsl_vector_short_const_view gsl_vector_short_const_view;
0065
0066
0067
0068
0069 gsl_vector_short *gsl_vector_short_alloc (const size_t n);
0070 gsl_vector_short *gsl_vector_short_calloc (const size_t n);
0071
0072 gsl_vector_short *gsl_vector_short_alloc_from_block (gsl_block_short * b,
0073 const size_t offset,
0074 const size_t n,
0075 const size_t stride);
0076
0077 gsl_vector_short *gsl_vector_short_alloc_from_vector (gsl_vector_short * v,
0078 const size_t offset,
0079 const size_t n,
0080 const size_t stride);
0081
0082 void gsl_vector_short_free (gsl_vector_short * v);
0083
0084
0085
0086 _gsl_vector_short_view
0087 gsl_vector_short_view_array (short *v, size_t n);
0088
0089 _gsl_vector_short_view
0090 gsl_vector_short_view_array_with_stride (short *base,
0091 size_t stride,
0092 size_t n);
0093
0094 _gsl_vector_short_const_view
0095 gsl_vector_short_const_view_array (const short *v, size_t n);
0096
0097 _gsl_vector_short_const_view
0098 gsl_vector_short_const_view_array_with_stride (const short *base,
0099 size_t stride,
0100 size_t n);
0101
0102 _gsl_vector_short_view
0103 gsl_vector_short_subvector (gsl_vector_short *v,
0104 size_t i,
0105 size_t n);
0106
0107 _gsl_vector_short_view
0108 gsl_vector_short_subvector_with_stride (gsl_vector_short *v,
0109 size_t i,
0110 size_t stride,
0111 size_t n);
0112
0113 _gsl_vector_short_const_view
0114 gsl_vector_short_const_subvector (const gsl_vector_short *v,
0115 size_t i,
0116 size_t n);
0117
0118 _gsl_vector_short_const_view
0119 gsl_vector_short_const_subvector_with_stride (const gsl_vector_short *v,
0120 size_t i,
0121 size_t stride,
0122 size_t n);
0123
0124
0125
0126 void gsl_vector_short_set_zero (gsl_vector_short * v);
0127 void gsl_vector_short_set_all (gsl_vector_short * v, short x);
0128 int gsl_vector_short_set_basis (gsl_vector_short * v, size_t i);
0129
0130 int gsl_vector_short_fread (FILE * stream, gsl_vector_short * v);
0131 int gsl_vector_short_fwrite (FILE * stream, const gsl_vector_short * v);
0132 int gsl_vector_short_fscanf (FILE * stream, gsl_vector_short * v);
0133 int gsl_vector_short_fprintf (FILE * stream, const gsl_vector_short * v,
0134 const char *format);
0135
0136 int gsl_vector_short_memcpy (gsl_vector_short * dest, const gsl_vector_short * src);
0137
0138 int gsl_vector_short_reverse (gsl_vector_short * v);
0139
0140 int gsl_vector_short_swap (gsl_vector_short * v, gsl_vector_short * w);
0141 int gsl_vector_short_swap_elements (gsl_vector_short * v, const size_t i, const size_t j);
0142
0143 short gsl_vector_short_max (const gsl_vector_short * v);
0144 short gsl_vector_short_min (const gsl_vector_short * v);
0145 void gsl_vector_short_minmax (const gsl_vector_short * v, short * min_out, short * max_out);
0146
0147 size_t gsl_vector_short_max_index (const gsl_vector_short * v);
0148 size_t gsl_vector_short_min_index (const gsl_vector_short * v);
0149 void gsl_vector_short_minmax_index (const gsl_vector_short * v, size_t * imin, size_t * imax);
0150
0151 int gsl_vector_short_add (gsl_vector_short * a, const gsl_vector_short * b);
0152 int gsl_vector_short_sub (gsl_vector_short * a, const gsl_vector_short * b);
0153 int gsl_vector_short_mul (gsl_vector_short * a, const gsl_vector_short * b);
0154 int gsl_vector_short_div (gsl_vector_short * a, const gsl_vector_short * b);
0155 int gsl_vector_short_scale (gsl_vector_short * a, const short x);
0156 int gsl_vector_short_add_constant (gsl_vector_short * a, const short x);
0157 int gsl_vector_short_axpby (const short alpha, const gsl_vector_short * x, const short beta, gsl_vector_short * y);
0158 short gsl_vector_short_sum (const gsl_vector_short * a);
0159
0160 int gsl_vector_short_equal (const gsl_vector_short * u,
0161 const gsl_vector_short * v);
0162
0163 int gsl_vector_short_isnull (const gsl_vector_short * v);
0164 int gsl_vector_short_ispos (const gsl_vector_short * v);
0165 int gsl_vector_short_isneg (const gsl_vector_short * v);
0166 int gsl_vector_short_isnonneg (const gsl_vector_short * v);
0167
0168 INLINE_DECL short gsl_vector_short_get (const gsl_vector_short * v, const size_t i);
0169 INLINE_DECL void gsl_vector_short_set (gsl_vector_short * v, const size_t i, short x);
0170 INLINE_DECL short * gsl_vector_short_ptr (gsl_vector_short * v, const size_t i);
0171 INLINE_DECL const short * gsl_vector_short_const_ptr (const gsl_vector_short * v, const size_t i);
0172
0173 #ifdef HAVE_INLINE
0174
0175 INLINE_FUN
0176 short
0177 gsl_vector_short_get (const gsl_vector_short * v, const size_t i)
0178 {
0179 #if GSL_RANGE_CHECK
0180 if (GSL_RANGE_COND(i >= v->size))
0181 {
0182 GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0);
0183 }
0184 #endif
0185 return v->data[i * v->stride];
0186 }
0187
0188 INLINE_FUN
0189 void
0190 gsl_vector_short_set (gsl_vector_short * v, const size_t i, short x)
0191 {
0192 #if GSL_RANGE_CHECK
0193 if (GSL_RANGE_COND(i >= v->size))
0194 {
0195 GSL_ERROR_VOID ("index out of range", GSL_EINVAL);
0196 }
0197 #endif
0198 v->data[i * v->stride] = x;
0199 }
0200
0201 INLINE_FUN
0202 short *
0203 gsl_vector_short_ptr (gsl_vector_short * v, const size_t i)
0204 {
0205 #if GSL_RANGE_CHECK
0206 if (GSL_RANGE_COND(i >= v->size))
0207 {
0208 GSL_ERROR_NULL ("index out of range", GSL_EINVAL);
0209 }
0210 #endif
0211 return (short *) (v->data + i * v->stride);
0212 }
0213
0214 INLINE_FUN
0215 const short *
0216 gsl_vector_short_const_ptr (const gsl_vector_short * v, const size_t i)
0217 {
0218 #if GSL_RANGE_CHECK
0219 if (GSL_RANGE_COND(i >= v->size))
0220 {
0221 GSL_ERROR_NULL ("index out of range", GSL_EINVAL);
0222 }
0223 #endif
0224 return (const short *) (v->data + i * v->stride);
0225 }
0226 #endif
0227
0228 __END_DECLS
0229
0230 #endif
0231
0232