Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/gsl/gsl_vector_ulong.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* vector/gsl_vector_ulong.h
0002  * 
0003  * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
0004  * 
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 3 of the License, or (at
0008  * your option) any later version.
0009  * 
0010  * This program is distributed in the hope that it will be useful, but
0011  * WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * General Public License for more details.
0014  * 
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef __GSL_VECTOR_ULONG_H__
0021 #define __GSL_VECTOR_ULONG_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_ulong.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 /* empty */
0037 # define __END_DECLS /* empty */
0038 #endif
0039 
0040 __BEGIN_DECLS
0041 
0042 typedef struct 
0043 {
0044   size_t size;
0045   size_t stride;
0046   unsigned long *data;
0047   gsl_block_ulong *block;
0048   int owner;
0049 } 
0050 gsl_vector_ulong;
0051 
0052 typedef struct
0053 {
0054   gsl_vector_ulong vector;
0055 } _gsl_vector_ulong_view;
0056 
0057 typedef _gsl_vector_ulong_view gsl_vector_ulong_view;
0058 
0059 typedef struct
0060 {
0061   gsl_vector_ulong vector;
0062 } _gsl_vector_ulong_const_view;
0063 
0064 typedef const _gsl_vector_ulong_const_view gsl_vector_ulong_const_view;
0065 
0066 
0067 /* Allocation */
0068 
0069 gsl_vector_ulong *gsl_vector_ulong_alloc (const size_t n);
0070 gsl_vector_ulong *gsl_vector_ulong_calloc (const size_t n);
0071 
0072 gsl_vector_ulong *gsl_vector_ulong_alloc_from_block (gsl_block_ulong * b,
0073                                                      const size_t offset, 
0074                                                      const size_t n, 
0075                                                      const size_t stride);
0076 
0077 gsl_vector_ulong *gsl_vector_ulong_alloc_from_vector (gsl_vector_ulong * v,
0078                                                       const size_t offset, 
0079                                                       const size_t n, 
0080                                                       const size_t stride);
0081 
0082 void gsl_vector_ulong_free (gsl_vector_ulong * v);
0083 
0084 /* Views */
0085 
0086 _gsl_vector_ulong_view 
0087 gsl_vector_ulong_view_array (unsigned long *v, size_t n);
0088 
0089 _gsl_vector_ulong_view 
0090 gsl_vector_ulong_view_array_with_stride (unsigned long *base,
0091                                          size_t stride,
0092                                          size_t n);
0093 
0094 _gsl_vector_ulong_const_view 
0095 gsl_vector_ulong_const_view_array (const unsigned long *v, size_t n);
0096 
0097 _gsl_vector_ulong_const_view 
0098 gsl_vector_ulong_const_view_array_with_stride (const unsigned long *base,
0099                                                size_t stride,
0100                                                size_t n);
0101 
0102 _gsl_vector_ulong_view 
0103 gsl_vector_ulong_subvector (gsl_vector_ulong *v, 
0104                             size_t i, 
0105                             size_t n);
0106 
0107 _gsl_vector_ulong_view 
0108 gsl_vector_ulong_subvector_with_stride (gsl_vector_ulong *v, 
0109                                         size_t i,
0110                                         size_t stride,
0111                                         size_t n);
0112 
0113 _gsl_vector_ulong_const_view 
0114 gsl_vector_ulong_const_subvector (const gsl_vector_ulong *v, 
0115                                   size_t i, 
0116                                   size_t n);
0117 
0118 _gsl_vector_ulong_const_view 
0119 gsl_vector_ulong_const_subvector_with_stride (const gsl_vector_ulong *v, 
0120                                               size_t i, 
0121                                               size_t stride,
0122                                               size_t n);
0123 
0124 /* Operations */
0125 
0126 void gsl_vector_ulong_set_zero (gsl_vector_ulong * v);
0127 void gsl_vector_ulong_set_all (gsl_vector_ulong * v, unsigned long x);
0128 int gsl_vector_ulong_set_basis (gsl_vector_ulong * v, size_t i);
0129 
0130 int gsl_vector_ulong_fread (FILE * stream, gsl_vector_ulong * v);
0131 int gsl_vector_ulong_fwrite (FILE * stream, const gsl_vector_ulong * v);
0132 int gsl_vector_ulong_fscanf (FILE * stream, gsl_vector_ulong * v);
0133 int gsl_vector_ulong_fprintf (FILE * stream, const gsl_vector_ulong * v,
0134                               const char *format);
0135 
0136 int gsl_vector_ulong_memcpy (gsl_vector_ulong * dest, const gsl_vector_ulong * src);
0137 
0138 int gsl_vector_ulong_reverse (gsl_vector_ulong * v);
0139 
0140 int gsl_vector_ulong_swap (gsl_vector_ulong * v, gsl_vector_ulong * w);
0141 int gsl_vector_ulong_swap_elements (gsl_vector_ulong * v, const size_t i, const size_t j);
0142 
0143 unsigned long gsl_vector_ulong_max (const gsl_vector_ulong * v);
0144 unsigned long gsl_vector_ulong_min (const gsl_vector_ulong * v);
0145 void gsl_vector_ulong_minmax (const gsl_vector_ulong * v, unsigned long * min_out, unsigned long * max_out);
0146 
0147 size_t gsl_vector_ulong_max_index (const gsl_vector_ulong * v);
0148 size_t gsl_vector_ulong_min_index (const gsl_vector_ulong * v);
0149 void gsl_vector_ulong_minmax_index (const gsl_vector_ulong * v, size_t * imin, size_t * imax);
0150 
0151 int gsl_vector_ulong_add (gsl_vector_ulong * a, const gsl_vector_ulong * b);
0152 int gsl_vector_ulong_sub (gsl_vector_ulong * a, const gsl_vector_ulong * b);
0153 int gsl_vector_ulong_mul (gsl_vector_ulong * a, const gsl_vector_ulong * b);
0154 int gsl_vector_ulong_div (gsl_vector_ulong * a, const gsl_vector_ulong * b);
0155 int gsl_vector_ulong_scale (gsl_vector_ulong * a, const unsigned long x);
0156 int gsl_vector_ulong_add_constant (gsl_vector_ulong * a, const unsigned long x);
0157 int gsl_vector_ulong_axpby (const unsigned long alpha, const gsl_vector_ulong * x, const unsigned long beta, gsl_vector_ulong * y);
0158 unsigned long gsl_vector_ulong_sum (const gsl_vector_ulong * a);
0159 
0160 int gsl_vector_ulong_equal (const gsl_vector_ulong * u, 
0161                             const gsl_vector_ulong * v);
0162 
0163 int gsl_vector_ulong_isnull (const gsl_vector_ulong * v);
0164 int gsl_vector_ulong_ispos (const gsl_vector_ulong * v);
0165 int gsl_vector_ulong_isneg (const gsl_vector_ulong * v);
0166 int gsl_vector_ulong_isnonneg (const gsl_vector_ulong * v);
0167 
0168 INLINE_DECL unsigned long gsl_vector_ulong_get (const gsl_vector_ulong * v, const size_t i);
0169 INLINE_DECL void gsl_vector_ulong_set (gsl_vector_ulong * v, const size_t i, unsigned long x);
0170 INLINE_DECL unsigned long * gsl_vector_ulong_ptr (gsl_vector_ulong * v, const size_t i);
0171 INLINE_DECL const unsigned long * gsl_vector_ulong_const_ptr (const gsl_vector_ulong * v, const size_t i);
0172 
0173 #ifdef HAVE_INLINE
0174 
0175 INLINE_FUN
0176 unsigned long
0177 gsl_vector_ulong_get (const gsl_vector_ulong * 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_ulong_set (gsl_vector_ulong * v, const size_t i, unsigned long 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 unsigned long *
0203 gsl_vector_ulong_ptr (gsl_vector_ulong * 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 (unsigned long *) (v->data + i * v->stride);
0212 }
0213 
0214 INLINE_FUN
0215 const unsigned long *
0216 gsl_vector_ulong_const_ptr (const gsl_vector_ulong * 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 unsigned long *) (v->data + i * v->stride);
0225 }
0226 #endif /* HAVE_INLINE */
0227 
0228 __END_DECLS
0229 
0230 #endif /* __GSL_VECTOR_ULONG_H__ */
0231 
0232