Debian Codegraph @

crm_svm_matrix.h

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 // crm_svm_matrix.h - Support Vector Machinecxx . . $ `<file>/crm_svm_matrix.h`/
2
3 ////////////////////////////////////////////////////////////////////////
4 // This code is originally copyright and owned by William
5 // S. Yerazunis as file crm_neural_net. In return for addition of
6 // significant derivative work, Jennifer Barry is hereby granted a full
7 // unlimited license to use this code, includng license to relicense under
8 // other licenses.
9 ////////////////////////////////////////////////////////////////////////
10 //
11 // Copyright 2009 William S. Yerazunis.
12 // This file is under GPLv3, as described in COPYING.
13
14 #ifndef __CRM_SVM_MATRIX__H
15 #define __CRM_SVM_MATRIX__Hcxx . . $ `crm_svm_matrix.h:15:9`!
16
17 #include "crm_svm_matrix_util.h"cxx . . $ `<file>/crm_svm_matrix_util.h`/
18
19 /*******************************************************************
20 *A matrix/vector library that deals with different data structures
21 *for representing vectors transparently.
22 *
23 *The functions in matrix.c are commented. See them for
24 *details on this library.
25 ******************************************************************/
26
27 #define MATR_DEFAULT_VECTOR_SIZEcxx . . $ `crm_svm_matrix.h:27:9`! 1200 //sparse arrays start at this size
28 //unless otherwise specified
29 #define MATR_COMPACTcxx . . $ `crm_svm_matrix.h:29:9`! 1
30 #define MATR_PRECISEcxx . . $ `crm_svm_matrix.h:30:9`! 0
31 #define QSORT_COUNTING_CUTOFFcxx . . $ `crm_svm_matrix.h:31:9`! 7e7 //with this many non-zero elts or above
32 //we use counting sort, not q-sort
33
34 extern int MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.; //debug setting. see crm_svm_matrix_util.h
35 //for possible modes
36
37 //Possible vector types.
38 typedef enumcxx . . $ $anonymous_type_4c10de060a7aee5b_0# {
39 NON_SPARSEcxx . . $ NON_SPARSE.,
40 SPARSE_ARRAYcxx . . $ SPARSE_ARRAY.,
41 SPARSE_LISTcxx . . $ SPARSE_LIST.
42 } VectorTypecxx . . $ VectorType#;
43
44 typedef enumcxx . . $ $anonymous_type_4c10de060a7aee5b_1# {
45 COUNTINGcxx . . $ COUNTING.,
46 MERGEcxx . . $ MERGE.,
47 QSORTcxx . . $ QSORT.
48 } SortingAlgorithmscxx . . $ SortingAlgorithms#;
49
50
51 typedef unioncxx . . $ $anonymous_type_4c10de060a7aee5b_2# {
52 PreciseSparseNodecxx . . $ PreciseSparseNode# *pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.;
53 CompactSparseNodecxx . . $ CompactSparseNode# *ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.;
54 long nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.;
55 } VectorIteratorcxx . . $ VectorIterator#;
56
57
58 //data for non-sparse
59 //can be either doubles or ints
60 typedef unioncxx . . $ $anonymous_type_4c10de060a7aee5b_3# {
61 int *compactcxx . . $ $anonymous_type_4c10de060a7aee5b_3#compact.;
62 double *precisecxx . . $ $anonymous_type_4c10de060a7aee5b_3#precise.;
63 } NSDatacxx . . $ NSData#;
64
65 //vectors can be either expanding arrays, lists,
66 //or arrays of NSData
67 typedef unioncxx . . $ $anonymous_type_4c10de060a7aee5b_4# {
68 ExpandingArraycxx . . $ ExpandingArray# *sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.; //SPARSSE_ARRAY vector
69 SparseElementListcxx . . $ SparseElementList# *splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.; //SPARSE_LIST vector
70 NSDatacxx . . $ NSData# nsarraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#nsarray.; //NON_SPARSE vector
71 } VectorDatacxx . . $ VectorData#;
72
73 //vector struct
74 typedef structcxx . . $ $anonymous_type_4c10de060a7aee5b_5# {
75 VectorDatacxx . . $ VectorData# datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data.; //data stored in the vector
76 unsigned int dimcxx . . $ $anonymous_type_4c10de060a7aee5b_5#dim.; //# columns (dimension) in the vector
77 int nzcxx . . $ $anonymous_type_4c10de060a7aee5b_5#nz., //# non-zero elements (nz = dim if v is NON_SPARSE)
78 compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact., //flag for compactness
79 sizecxx . . $ $anonymous_type_4c10de060a7aee5b_5#size., //starting size for expanding arrays
80 was_mappedcxx . . $ $anonymous_type_4c10de060a7aee5b_5#was_mapped.; //1 if the vector was mapped into memory
81 VectorTypecxx . . $ VectorType# typecxx . . $ $anonymous_type_4c10de060a7aee5b_5#type.; //flag for type
82 } Vectorcxx . . $ Vector#;
83
84 //matrix struct
85 typedef structcxx . . $ $anonymous_type_4c10de060a7aee5b_6# {
86 Vectorcxx . . $ Vector# **datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data.; //list of pointers to rows
87 unsigned int rowscxx . . $ $anonymous_type_4c10de060a7aee5b_6#rows., //# rows in the matrix
88 colscxx . . $ $anonymous_type_4c10de060a7aee5b_6#cols.; //# columns in the matrix
89 int nzcxx . . $ $anonymous_type_4c10de060a7aee5b_6#nz., //# non-zero elements (nz = rows*cols if M is NON_SPARSE)
90 compactcxx . . $ $anonymous_type_4c10de060a7aee5b_6#compact., //flag for compactness
91 sizecxx . . $ $anonymous_type_4c10de060a7aee5b_6#size., //starting size for expanding arrays
92 was_mappedcxx . . $ $anonymous_type_4c10de060a7aee5b_6#was_mapped.; //1 if the matrix was mapped into memory
93 VectorTypecxx . . $ VectorType# typecxx . . $ $anonymous_type_4c10de060a7aee5b_6#type.; //flag for type
94 } Matrixcxx . . $ Matrix#;
95
96 //Matrix functions
97 Matrixcxx . . $ Matrix# *matr_makecxx . . $ matr_make(b87a8eee0f302777).(unsigned int rows, unsigned int cols, VectorTypecxx . . $ VectorType# type,
98 int compact);
99 Matrixcxx . . $ Matrix# *matr_make_sizecxx . . $ matr_make_size(a51a6d7b0be3e1ff).(unsigned int rows, unsigned int cols, VectorTypecxx . . $ VectorType# type,
100 int compact, int init_size);
101 void matr_set_rowcxx . . $ matr_set_row(de955128da68bc77).(Matrixcxx . . $ Matrix# *A, unsigned int r, Vectorcxx . . $ Vector# *v);
102 void matr_shallow_row_copycxx . . $ matr_shallow_row_copy(de955128da68bc77).(Matrixcxx . . $ Matrix# *M, unsigned int r, Vectorcxx . . $ Vector# *v);
103 void matr_set_colcxx . . $ matr_set_col(de955128da68bc77).(Matrixcxx . . $ Matrix# *A, unsigned int c, Vectorcxx . . $ Vector# *v);
104 void matr_add_rowcxx . . $ matr_add_row(3934fb60891d3891).(Matrixcxx . . $ Matrix# *M);
105 void matr_add_nrowscxx . . $ matr_add_nrows(5fe60fe5d5ffed44).(Matrixcxx . . $ Matrix# *M, unsigned int n);
106 void matr_add_colcxx . . $ matr_add_col(3934fb60891d3891).(Matrixcxx . . $ Matrix# *M);
107 void matr_add_ncolscxx . . $ matr_add_ncols(5fe60fe5d5ffed44).(Matrixcxx . . $ Matrix# *M, unsigned int n);
108 void matr_remove_rowcxx . . $ matr_remove_row(5fe60fe5d5ffed44).(Matrixcxx . . $ Matrix# *M, unsigned int r);
109 void matr_erase_rowcxx . . $ matr_erase_row(5fe60fe5d5ffed44).(Matrixcxx . . $ Matrix# *M, unsigned int r);
110 void matr_remove_colcxx . . $ matr_remove_col(5fe60fe5d5ffed44).(Matrixcxx . . $ Matrix# *M, unsigned int c);
111 ExpandingArraycxx . . $ ExpandingArray# *matr_remove_zero_rowscxx . . $ matr_remove_zero_rows(770f4a15bcf35a94).(Matrixcxx . . $ Matrix# *M);
112 ExpandingArraycxx . . $ ExpandingArray# *matr_remove_zero_colscxx . . $ matr_remove_zero_cols(770f4a15bcf35a94).(Matrixcxx . . $ Matrix# *M);
113 void matr_append_matrcxx . . $ matr_append_matr(e29dd54017fb30ed).(Matrixcxx . . $ Matrix# **to_ptr, Matrixcxx . . $ Matrix# *from);
114 void matr_vectorcxx . . $ matr_vector(7492d500fef89dda).(Matrixcxx . . $ Matrix# *M, Vectorcxx . . $ Vector# *v, Vectorcxx . . $ Vector# *ret);
115 void matr_vector_seqcxx . . $ matr_vector_seq(975ce9942453a0ff).(Matrixcxx . . $ Matrix# **A, int nmatrices, unsigned int maxrows,
116 Vectorcxx . . $ Vector# *w, Vectorcxx . . $ Vector# *z);
117 void matr_transposecxx . . $ matr_transpose(3ea7a5ca925eac93).(Matrixcxx . . $ Matrix# *A, Matrixcxx . . $ Matrix# *T);
118 void matr_multiplycxx . . $ matr_multiply(6d4b365efef52180).(Matrixcxx . . $ Matrix# *M1, Matrixcxx . . $ Matrix# *M2, Matrixcxx . . $ Matrix# *ret);
119 int matr_iszerocxx . . $ matr_iszero(46747c78951717a3).(Matrixcxx . . $ Matrix# *M);
120 void matr_convert_nonsparse_to_sparraycxx . . $ matr_convert_nonsparse_to_sparray(746847fb84512260).(Matrixcxx . . $ Matrix# *M, ExpandingArraycxx . . $ ExpandingArray# *colMap);
121 void matr_printcxx . . $ matr_print(3934fb60891d3891).(Matrixcxx . . $ Matrix# *M);
122 void matr_writecxx . . $ matr_write(c8ab925bf79c5f3).(Matrixcxx . . $ Matrix# *M, char *filename);
123 void matr_write_fpcxx . . $ matr_write_fp(2ccadfe55e05d49e).(Matrixcxx . . $ Matrix# *M, FILEcxx . . $ FILE# *out);
124 size_t matr_write_bincxx . . $ matr_write_bin(d33f8b6a8ea6ca6a).(Matrixcxx . . $ Matrix# *M, char *filename);
125 size_t matr_write_bin_fpcxx . . $ matr_write_bin_fp(5aafe98117a37d91).(Matrixcxx . . $ Matrix# *M, FILEcxx . . $ FILE# *fp);
126 Matrixcxx . . $ Matrix# *matr_read_bincxx . . $ matr_read_bin(f22f842b31367ed8).(char *filename);
127 Matrixcxx . . $ Matrix# *matr_read_bin_fpcxx . . $ matr_read_bin_fp(842209a14ed3e109).(FILEcxx . . $ FILE# *fp);
128 Matrixcxx . . $ Matrix# *matr_mapcxx . . $ matr_map(8b207b3267dd6205).(void **addr, void *last_addr);
129 void matr_freecxx . . $ matr_free(3934fb60891d3891).(Matrixcxx . . $ Matrix# *M);
130
131 //inlined matrix functions defined in this file
132 //(inlining is compiler discretion)
133 static inline void matr_setcxx . . $ matr_set(b9e2255798d6c11c).(Matrixcxx . . $ Matrix# *M, unsigned int r, unsigned int c,
134 double d);
135 static inline double matr_getcxx . . $ matr_get(36b39e6decbc6936).(Matrixcxx . . $ Matrix# *M, unsigned int r, unsigned int c);
136 static inline Vectorcxx . . $ Vector# *matr_get_rowcxx . . $ matr_get_row(74fc5042b07786a7).(Matrixcxx . . $ Matrix# *M, unsigned int r);
137
138
139 //Vector functions
140 Vectorcxx . . $ Vector# *vector_makecxx . . $ vector_make(c23861d8092366df).(unsigned int dim, VectorTypecxx . . $ VectorType# type, int compact);
141 Vectorcxx . . $ Vector# *vector_make_sizecxx . . $ vector_make_size(b7b902fe7e1fb43b).(unsigned int dim, VectorTypecxx . . $ VectorType# type, int compact,
142 int init_size);
143 void vector_copycxx . . $ vector_copy(6caaca33a20f4da4).(Vectorcxx . . $ Vector# *from, Vectorcxx . . $ Vector# *to);
•144 void vector_setcxx . . $ vector_set(a7b9ba29cac897fa).(Vectorcxx . . $ Vector# *v, unsigned int i, double d);
145 double vector_getcxx . . $ vector_get(e3029172505e752a).(Vectorcxx . . $ Vector# *v, unsigned int i);
146 void vector_add_colcxx . . $ vector_add_col(38f8fa05eb588be3).(Vectorcxx . . $ Vector# *v);
147 void vector_add_ncolscxx . . $ vector_add_ncols(fd526f8518c84b96).(Vectorcxx . . $ Vector# *v, unsigned int n);
148 void vector_remove_colcxx . . $ vector_remove_col(fd526f8518c84b96).(Vectorcxx . . $ Vector# *v, unsigned int c);
•149 int vector_iszerocxx . . $ vector_iszero(4d6de86b78c76686).(Vectorcxx . . $ Vector# *V);
150 int vector_equalscxx . . $ vector_equals(5f1e11b0726e6bac).(Vectorcxx . . $ Vector# *v1, Vectorcxx . . $ Vector# *v2);
•151 void vector_zerocxx . . $ vector_zero(38f8fa05eb588be3).(Vectorcxx . . $ Vector# *v);
152 void vector_addcxx . . $ vector_add(f7d32fbcfa32fcae).(Vectorcxx . . $ Vector# *v1, Vectorcxx . . $ Vector# *v2, Vectorcxx . . $ Vector# *ret);
153 void vector_multiplycxx . . $ vector_multiply(af9c00fc4e829008).(Vectorcxx . . $ Vector# *v, double s, Vectorcxx . . $ Vector# *ret);
154 double dotcxx . . $ dot(e3529417f583c16c).(Vectorcxx . . $ Vector# *v1, Vectorcxx . . $ Vector# *v2);
155 void vector_add_multiplecxx . . $ vector_add_multiple(5d28f5ac982bab4d).(Vectorcxx . . $ Vector# *base, Vectorcxx . . $ Vector# *toadd,
156 double factor, Vectorcxx . . $ Vector# *ret);
157 double vector_dist2cxx . . $ vector_dist2(e3529417f583c16c).(Vectorcxx . . $ Vector# *v1, Vectorcxx . . $ Vector# *v2);
158 void vector_convert_nonsparse_to_sparraycxx . . $ vector_convert_nonsparse_to_sparray(7b34f8f2533c9fa).(Vectorcxx . . $ Vector# *v, ExpandingArraycxx . . $ ExpandingArray# *colMap);
159 void vector_printcxx . . $ vector_print(38f8fa05eb588be3).(Vectorcxx . . $ Vector# *v);
160 void vector_writecxx . . $ vector_write(2e0f43f514a36c3e).(Vectorcxx . . $ Vector# *v, char *filename);
161 void vector_write_fpcxx . . $ vector_write_fp(afa61ec53adba5da).(Vectorcxx . . $ Vector# *v, FILEcxx . . $ FILE# *out);
162 void vector_write_spcxx . . $ vector_write_sp(2e0f43f514a36c3e).(Vectorcxx . . $ Vector# *v, char *filename);
163 void vector_write_sp_fpcxx . . $ vector_write_sp_fp(afa61ec53adba5da).(Vectorcxx . . $ Vector# *v, FILEcxx . . $ FILE# *out);
164 size_t vector_write_bincxx . . $ vector_write_bin(115b68488a517383).(Vectorcxx . . $ Vector# *v, char *filename);
165 size_t vector_write_bin_fpcxx . . $ vector_write_bin_fp(446f9ed4e171e8a1).(Vectorcxx . . $ Vector# *v, FILEcxx . . $ FILE# *fp);
166 Vectorcxx . . $ Vector# *vector_read_bincxx . . $ vector_read_bin(5922b485609a319b).(char *filename);
167 Vectorcxx . . $ Vector# *vector_read_bin_fpcxx . . $ vector_read_bin_fp(4a2fcd787605c1a8).(FILEcxx . . $ FILE# *fp);
168 Vectorcxx . . $ Vector# *vector_mapcxx . . $ vector_map(f43c322b10fe41e3).(void **addr, void *last_addr);
169 void *vector_memmovecxx . . $ vector_memmove(34f670f29c4a0efb).(void *to, Vectorcxx . . $ Vector# *from);
170 size_t vector_sizecxx . . $ vector_size(2e40cb700cc1d6ee).(Vectorcxx . . $ Vector# *v);
171 void vector_freecxx . . $ vector_free(38f8fa05eb588be3).(Vectorcxx . . $ Vector# *v);
172
173 //inline'd functions defined in this file
174 //(inlining is compiler discretion)
175 static inline unsigned int vector_dimcxx . . $ vector_dim(5fa792433de1b888).(Vectorcxx . . $ Vector# *v);
176 static inline int vector_num_eltscxx . . $ vector_num_elts(4d6de86b78c76686).(Vectorcxx . . $ Vector# *v);
177 static inline double norm2cxx . . $ norm2(be172cfd042450e9).(Vectorcxx . . $ Vector# *v);
178 static inline double normcxx . . $ norm(be172cfd042450e9).(Vectorcxx . . $ Vector# *v);
179 static inline double vector_distcxx . . $ vector_dist(e3529417f583c16c).(Vectorcxx . . $ Vector# *v1, Vectorcxx . . $ Vector# *v2) ;
180
181 //Vector iterator functions
182 void vectorit_zero_eltcxx . . $ vectorit_zero_elt(e216517ed0835285).(VectorIteratorcxx . . $ VectorIterator# *vit, Vectorcxx . . $ Vector# *v);
183 void vectorit_insertcxx . . $ vectorit_insert(3f3bc7737d6f7c82).(VectorIteratorcxx . . $ VectorIterator# *vit, unsigned int c, double d, Vectorcxx . . $ Vector# *v);
184 void vectorit_findcxx . . $ vectorit_find(a77df814ba28e67e).(VectorIteratorcxx . . $ VectorIterator# *vit, unsigned int c, Vectorcxx . . $ Vector# *v);
•185 void vectorit_set_colcxx . . $ vectorit_set_col(7cf9d0244457b216).(VectorIteratorcxx . . $ VectorIterator# vit, unsigned int c, Vectorcxx . . $ Vector# *v);
186
187 //defined in this file - forced to be inline'd at high optimization
188 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_set_at_begcxx . . $ vectorit_set_at_beg(e216517ed0835285).(VectorIteratorcxx . . $ VectorIterator# *vit, Vectorcxx . . $ Vector# *v);
189 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_set_at_endcxx . . $ vectorit_set_at_end(e216517ed0835285).(VectorIteratorcxx . . $ VectorIterator# *vit, Vectorcxx . . $ Vector# *v);
190 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! double vectorit_curr_valcxx . . $ vectorit_curr_val(b3120ea66c3b2b71).(VectorIteratorcxx . . $ VectorIterator# vit, Vectorcxx . . $ Vector# *v);
191 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! unsigned int vectorit_curr_colcxx . . $ vectorit_curr_col(5683b49da806b1f8).(VectorIteratorcxx . . $ VectorIterator# vit, Vectorcxx . . $ Vector# *v);
192 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_prevcxx . . $ vectorit_prev(e216517ed0835285).(VectorIteratorcxx . . $ VectorIterator# *vit, Vectorcxx . . $ Vector# *v);
193 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_nextcxx . . $ vectorit_next(e216517ed0835285).(VectorIteratorcxx . . $ VectorIterator# *vit, Vectorcxx . . $ Vector# *v);
194 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! int vectorit_past_endcxx . . $ vectorit_past_end(8e262e4b8953a5c6).(VectorIteratorcxx . . $ VectorIterator# vit, Vectorcxx . . $ Vector# *v);
195 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! int vectorit_past_begcxx . . $ vectorit_past_beg(8e262e4b8953a5c6).(VectorIteratorcxx . . $ VectorIterator# vit, Vectorcxx . . $ Vector# *v);
196 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_copycxx . . $ vectorit_copy(164c04d928980008).(VectorIteratorcxx . . $ VectorIterator# from, VectorIteratorcxx . . $ VectorIterator# *to);
197
198
199 /*************INLINE FUNCTION DEFINITIONS***********************************/
200
201
202 //Matrix
203 /*************************************************************************
204 *Gets a pointer to a row of a matrix.
205 *
206 *INPUT: A: matrix from which to get a row.
207 * r: row to get.
208 *
209 *OUTPUT: A pointer to row r of matrix M.
210 *
211 *TIME:
212 * NON_SPARSE: O(1)
213 * SPARSE_ARRAY: O(1)
214 * SPARSE_LIST: O(1)
215 *************************************************************************/
216
217 static inline Vectorcxx . . $ Vector# *matr_get_rowcxx . . $ matr_get_row(74fc5042b07786a7).(Matrixcxx . . $ Matrix# *A, unsigned int r) {
218 //yay, easy :)
219 if (A && A->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data. && r >= 0 && r < A->rowscxx . . $ $anonymous_type_4c10de060a7aee5b_6#rows.) {
220 return A->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data.[r];
221 }
222 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
223 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "matr_get_row: bad arguments.\n");
224 }
225 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
226 }
227
228 /*************************************************************************
229 *Sets an entry of a matrix.
230 *
231 *INPUT: M: matrix in which to set an entry.
232 * r: row of the entry.
233 * c: column of the entry.
234 * d: value to set the entry to.
235 *
236 *TIME:
237 * NON_SPARSE: O(1)
238 * SPARSE_ARRAY: d is non-zero = ammortized O(lg(S/R)), d = 0 = O(S/R)
239 * SPARSE_LIST: O(S/R)
240 *************************************************************************/
241
242 static inline void matr_setcxx . . $ matr_set(b9e2255798d6c11c).(Matrixcxx . . $ Matrix# *M, unsigned int r, unsigned int c,
243 double d) {
244 int nz;
245 if (!M || !M->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data. || r < 0 || r >= M->rowscxx . . $ $anonymous_type_4c10de060a7aee5b_6#rows. || !M->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data.[r]) {
246 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
247 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "matr_set: bad arguments.\n");
248 }
249 return;
250 }
251 nz = M->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data.[r]->nzcxx . . $ $anonymous_type_4c10de060a7aee5b_5#nz.;
252 vector_setcxx . . $ vector_set(a7b9ba29cac897fa).(M->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data.[r], c, d);
253 M->nzcxx . . $ $anonymous_type_4c10de060a7aee5b_6#nz. += M->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data.[r]->nzcxx . . $ $anonymous_type_4c10de060a7aee5b_5#nz. - nz;
254 }
255
256 /*************************************************************************
257 *Gets an entry of a matrix.
258 *
259 *INPUT: M: matrix from which to get an entry.
260 * r: row of the entry.
261 * c: column of the entry.
262 *
263 *OUTPUT: the value at r,c of matrix M
264 *
265 *TIME:
266 * NON_SPARSE: O(1)
267 * SPARSE_ARRAY: O(lg(S/R))
268 * SPARSE_LIST: O(S/R)
269 *************************************************************************/
270
271 static inline double matr_getcxx . . $ matr_get(36b39e6decbc6936).(Matrixcxx . . $ Matrix# *M, unsigned int r, unsigned int c) {
272 if (!M || !M->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data. || r < 0 || r >= M->rowscxx . . $ $anonymous_type_4c10de060a7aee5b_6#rows. || !M->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data.[r]) {
273 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
274 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "matr_set: bad arguments.\n");
275 }
276 return 0;
277 }
278 return vector_getcxx . . $ vector_get(e3029172505e752a).(M->datacxx . . $ $anonymous_type_4c10de060a7aee5b_6#data.[r], c);
279 }
280
281 //Vector
282
283
284
285
286 /*************************************************************************
287 *Dimension of a vector.
288 *
289 *INPUT: v: vector
290 *
291 *OUTPUT: The dimension (ie number of rows/columns) of v
292 *
293 *TIME:
294 * NON_SPARSE: O(1)
295 * SPARSE_ARRAY: O(1)
296 * SPARSE_LIST: O(1)
297 *************************************************************************/
298
299 static inline unsigned int vector_dimcxx . . $ vector_dim(5fa792433de1b888).(Vectorcxx . . $ Vector# *v) {
300 if (!v) {
301 return 0;
302 }
303 return v->dimcxx . . $ $anonymous_type_4c10de060a7aee5b_5#dim.;
304 }
305
306 /*************************************************************************
307 *Number of elements of a vector.
308 *
309 *INPUT: v: vector
310 *
311 *OUTPUT: The dimension (ie number of rows/columns) of v if v is NON_SPARSE
312 * or the number of non-zero elements of v if v is SPARSE
313 *
314 *TIME:
315 * NON_SPARSE: O(1)
316 * SPARSE_ARRAY: O(1)
317 * SPARSE_LIST: O(1)
318 *************************************************************************/
319
320 static inline int vector_num_eltscxx . . $ vector_num_elts(4d6de86b78c76686).(Vectorcxx . . $ Vector# *v) {
321 if (!v) {
322 return 0;
323 }
324 return v->nzcxx . . $ $anonymous_type_4c10de060a7aee5b_5#nz.;
325 }
326
327
328 /*************************************************************************
329 *Squared norm. Note that finding square roots can be time consuming so
330 *use this function to avoid that when possible.
331 *
332 *INPUT: v: vector to find the norm of
333 *
334 *OUTPUT: ||v||^2
335 *
336 *TIME:
337 * NON_SPARSE: O(c)
338 * SPARSE_ARRAY: O(s)
339 * SPARSE_LIST: O(s)
340 *************************************************************************/
341
342 static inline double norm2cxx . . $ norm2(be172cfd042450e9).(Vectorcxx . . $ Vector# *v) {
343 return dotcxx . . $ dot(e3529417f583c16c).(v, v);
344 }
345
346 /*************************************************************************
347 *Norm of a vector.
348 *
349 *INPUT: v: vector to find the norm of
350 *
351 *OUTPUT: ||v||
352 *
353 *TIME:
354 * NON_SPARSE: O(c)
355 * SPARSE_ARRAY: O(s)
356 * SPARSE_LIST: O(s)
357 *************************************************************************/
358
359 static inline double normcxx . . $ norm(be172cfd042450e9).(Vectorcxx . . $ Vector# *v) {
360 return (sqrt(dotcxx . . $ dot(e3529417f583c16c).(v,v)));
361 }
362
363
364 /*************************************************************************
365 *Distance between two vectors.
366 *
367 *INPUT: v1: first vector
368 * v2: second vector
369 *
370 *OUTPUT: ||v1 - v2||
371 *
372 *TIME:
373 * Both NON_SPARSE: O(c)
374 * One NON_SPARSE, one SPARSE: O(s) + O(c)
375 * Both SPARSE: O(s_1) + O(s_2)
376 *************************************************************************/
377
378 static inline double vector_distcxx . . $ vector_dist(e3529417f583c16c).(Vectorcxx . . $ Vector# *v1, Vectorcxx . . $ Vector# *v2) {
379 double d = vector_dist2cxx . . $ vector_dist2(e3529417f583c16c).(v1, v2);
380
381 if (d > 0) {
382 return sqrt(d);
383 }
384
385 return -1;
386 }
387
388
389 //Vector Iterator functions
390
391 /*************************************************************************
392 *Set the iterator to the beginning of a vector.
393 *
394 *INPUT: v: vector to traverse from the beginning
395 *
396 *OUTPUT: vit is set to the beginning of vector v
397 *
398 *TIME:
399 * NON_SPARSE: O(1)
400 * SPARSE_ARRAY: O(1)
401 * SPARSE_LIST: O(1)
402 *************************************************************************/
403
404 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_set_at_begcxx . . $ vectorit_set_at_beg(e216517ed0835285).(VectorIteratorcxx . . $ VectorIterator# *vit, Vectorcxx . . $ Vector# *v) {
405
406 if (!v || !vit) {
407 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
408 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "vectorit_set_at_beg: null arguments.\n");
409 }
410 if (vit) {
411 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = -1;
412 }
413 return;
414 }
415
416 switch (v->typecxx . . $ $anonymous_type_4c10de060a7aee5b_5#type.) {
417 case NON_SPARSEcxx . . $ NON_SPARSE.:
418 {
419 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = 0;
420 return;
421 }
422 case SPARSE_ARRAYcxx . . $ SPARSE_ARRAY.:
423 {
424 //nscurr needs to be the actual index
425 //in order that zero-ing an element in vector_add etc
426 //doesn't mess things up
427 if (!v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.) {
428 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = 0;
429 } else {
430 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->first_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#first_elt.;
431 }
432 return;
433 }
434 case SPARSE_LISTcxx . . $ SPARSE_LIST.:
435 {
436 if (v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.) {
437 if (v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.) {
438 vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr. = (v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.->headcxx . . $ $anonymous_type_6da04880c2c107c6_8#head..compactcxx . . $ $anonymous_type_6da04880c2c107c6_7#compact.);
439 } else {
440 vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
441 }
442 } else {
443 if (v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.) {
444 vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr. = (v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.->headcxx . . $ $anonymous_type_6da04880c2c107c6_8#head..precisecxx . . $ $anonymous_type_6da04880c2c107c6_7#precise.);
445 } else {
446 vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
447 }
448 }
449 return;
450 }
451 default:
452 {
453 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = -1;
454 return;
455 }
456 }
457 }
458
459
460 /*************************************************************************
461 *Set the iterator to the end of a vector.
462 *
463 *INPUT: v: vector to traverse from the end
464 *
465 *OUTPUT: vit is set to the end of vector v
466 *
467 *TIME:
468 * NON_SPARSE: O(1)
469 * SPARSE_ARRAY: O(1)
470 * SPARSE_LIST: O(1)
471 *************************************************************************/
472
473 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_set_at_endcxx . . $ vectorit_set_at_end(e216517ed0835285).(VectorIteratorcxx . . $ VectorIterator# *vit, Vectorcxx . . $ Vector# *v) {
474
475 if (!v || !vit) {
476 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
477 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "vectorit_set_at_end: null arguments.\n");
478 }
479 if (vit) {
480 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = -1;
481 }
482 return;
483 }
484
485 switch (v->typecxx . . $ $anonymous_type_4c10de060a7aee5b_5#type.) {
486 case NON_SPARSEcxx . . $ NON_SPARSE.:
487 {
488 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = v->dimcxx . . $ $anonymous_type_4c10de060a7aee5b_5#dim.-1;
489 break;
490 }
491 case SPARSE_ARRAYcxx . . $ SPARSE_ARRAY.:
492 {
493 if (!v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.) {
494 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = 0;
495 } else {
496 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->last_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#last_elt.;
497 }
498 break;
499 }
500 case SPARSE_LISTcxx . . $ SPARSE_LIST.:
501 {
502 if (v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.) {
503 if (!v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.) {
504 vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
505 } else {
506 vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr. = v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.->tailcxx . . $ $anonymous_type_6da04880c2c107c6_8#tail..compactcxx . . $ $anonymous_type_6da04880c2c107c6_7#compact.;
507 }
508 } else {
509 if (!v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.) {
510 vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
511 } else {
512 vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr. = v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.->tailcxx . . $ $anonymous_type_6da04880c2c107c6_8#tail..precisecxx . . $ $anonymous_type_6da04880c2c107c6_7#precise.;
513 }
514 }
515 break;
516 }
517 default:
518 {
519 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = -1;
520 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
521 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "vectorit_set_at_end: unrecognized type.\n");
522 }
523 return;
524 }
525 }
526 }
527
528 /*************************************************************************
529 *Get the value (data) of the element that the iterator is pointing to.
530 *
531 *INPUT: vit: the vector iterator, pointing to some element in v
532 * v: the vector vit is traversing
533 *
534 *OUTPUT: The data associated with the element vit is pointing to or
535 * -RAND_MAX if vit is not traversing v.
536 *
537 *TIME:
538 * NON_SPARSE: O(1)
539 * SPARSE_ARRAY: O(1)
540 * SPARSE_LIST: O(1)
541 *************************************************************************/
542
543 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! double vectorit_curr_valcxx . . $ vectorit_curr_val(b3120ea66c3b2b71).(VectorIteratorcxx . . $ VectorIterator# vit, Vectorcxx . . $ Vector# *v) {
544
545 if (!v) {
546 //if (MATR_DEBUG_MODE) {
547 //fprintf(stderr, "vectorit_curr_col: null vector.\n");
548 //}
549 return -RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:87:9`!;
550 }
551
552 switch (v->typecxx . . $ $anonymous_type_4c10de060a7aee5b_5#type.) {
553 case SPARSE_ARRAYcxx . . $ SPARSE_ARRAY.:
554 if (v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray. &&
555 vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. >= v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->first_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#first_elt. &&
556 vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. <= v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->last_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#last_elt.) {
557 if (v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact. && v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->datacxx . . $ $anonymous_type_6da04880c2c107c6_6#data..compactcxx . . $ $anonymous_type_6da04880c2c107c6_5#compact.) {
558 return (double)v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->datacxx . . $ $anonymous_type_6da04880c2c107c6_6#data..compactcxx . . $ $anonymous_type_6da04880c2c107c6_5#compact.[vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.].scxx . . $ $anonymous_type_6da04880c2c107c6_4#s..datacxx . . $ $anonymous_type_6da04880c2c107c6_1#data.;
559 }
560 if (!(v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.) && (v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->datacxx . . $ $anonymous_type_6da04880c2c107c6_6#data..precisecxx . . $ $anonymous_type_6da04880c2c107c6_5#precise.)) {
561 return v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->datacxx . . $ $anonymous_type_6da04880c2c107c6_6#data..precisecxx . . $ $anonymous_type_6da04880c2c107c6_5#precise.[vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.].scxx . . $ $anonymous_type_6da04880c2c107c6_3#s..datacxx . . $ $anonymous_type_6da04880c2c107c6_0#data.;
562 }
563 }
564 return -RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:87:9`!;
565 case SPARSE_LISTcxx . . $ SPARSE_LIST.:
566 {
567 if (v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact. && vit.ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.) {
568 return (double)vit.ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.->datacxx . . $ compact_mythical_node#data..datacxx . . $ $anonymous_type_6da04880c2c107c6_1#data.;
569 }
570 if (!(v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.) && vit.pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.) {
571 return vit.pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.->datacxx . . $ precise_mythical_node#data..datacxx . . $ $anonymous_type_6da04880c2c107c6_0#data.;
572 }
573 return -RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:87:9`!;
574 }
575 case NON_SPARSEcxx . . $ NON_SPARSE.:
576 {
577 if (vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. >= 0 && vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. < v->dimcxx . . $ $anonymous_type_4c10de060a7aee5b_5#dim.) {
578 if (v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact. && v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..nsarraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#nsarray..compactcxx . . $ $anonymous_type_4c10de060a7aee5b_3#compact.) {
579 return (double)v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..nsarraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#nsarray..compactcxx . . $ $anonymous_type_4c10de060a7aee5b_3#compact.[vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.];
580 }
581 if (!(v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.) && v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..nsarraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#nsarray..precisecxx . . $ $anonymous_type_4c10de060a7aee5b_3#precise.) {
582 return v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..nsarraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#nsarray..precisecxx . . $ $anonymous_type_4c10de060a7aee5b_3#precise.[vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.];
583 }
584 }
585 return -RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:87:9`!;
586 }
587 default:
588 {
589 return -RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:87:9`!;
590 }
591 }
592
593 return -RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:87:9`!;
594
595 }
596
597 /*************************************************************************
598 *Get the column of the element that the iterator is pointing to.
599 *
600 *INPUT: vit: the vector iterator, pointing to some element in v
601 * v: the vector vit is traversing
602 *
603 *OUTPUT: The column associated with the element vit is pointing to or v->dim
604 * if vit is past the beginning or end of v.
605 *
606 *TIME:
607 * NON_SPARSE: O(1)
608 * SPARSE_ARRAY: O(1)
609 * SPARSE_LIST: O(1)
610 *
611 *WARNINGS:
612 *1) This returns v->dim even if vit is past the BEGINNING of v. This is
613 * because column numbers need to be unsigned. Therefore, you need
614 * to explicitly check if an iterator is past the beginning of a vector
615 * - you can't count on this returning a negative value if the iterator
616 * is past the beginning.
617 *************************************************************************/
618
619 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! unsigned int vectorit_curr_colcxx . . $ vectorit_curr_col(5683b49da806b1f8).(VectorIteratorcxx . . $ VectorIterator# vit, Vectorcxx . . $ Vector# *v) {
620
621 if (!v) {
622 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
623 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "vectorit_curr_col: null vector.\n");
624 }
625 return MAX_INT_VALcxx . . $ `crm_svm_matrix_util.h:37:9`!;
626 }
627
628 switch (v->typecxx . . $ $anonymous_type_4c10de060a7aee5b_5#type.) {
629 case SPARSE_ARRAYcxx . . $ SPARSE_ARRAY.:
630 if (v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray. && v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->datacxx . . $ $anonymous_type_6da04880c2c107c6_6#data..compactcxx . . $ $anonymous_type_6da04880c2c107c6_5#compact. &&
631 vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. >= v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->first_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#first_elt. &&
632 vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. <= v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->last_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#last_elt.) {
633 if (v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact. && v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->datacxx . . $ $anonymous_type_6da04880c2c107c6_6#data..compactcxx . . $ $anonymous_type_6da04880c2c107c6_5#compact.) {
634 return v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->datacxx . . $ $anonymous_type_6da04880c2c107c6_6#data..compactcxx . . $ $anonymous_type_6da04880c2c107c6_5#compact.[vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.].scxx . . $ $anonymous_type_6da04880c2c107c6_4#s..colcxx . . $ $anonymous_type_6da04880c2c107c6_1#col.;
635 }
636 if (!(v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.) && (v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->datacxx . . $ $anonymous_type_6da04880c2c107c6_6#data..precisecxx . . $ $anonymous_type_6da04880c2c107c6_5#precise.)) {
637 return v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->datacxx . . $ $anonymous_type_6da04880c2c107c6_6#data..precisecxx . . $ $anonymous_type_6da04880c2c107c6_5#precise.[vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.].scxx . . $ $anonymous_type_6da04880c2c107c6_3#s..colcxx . . $ $anonymous_type_6da04880c2c107c6_0#col.;
638 }
639 }
640 return v->dimcxx . . $ $anonymous_type_4c10de060a7aee5b_5#dim.;
641 case SPARSE_LISTcxx . . $ SPARSE_LIST.:
642 {
643 if (v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact. && vit.ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.) {
644 return vit.ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.->datacxx . . $ compact_mythical_node#data..colcxx . . $ $anonymous_type_6da04880c2c107c6_1#col.;
645 }
646 if (!(v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.) && vit.pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.) {
647 return vit.pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.->datacxx . . $ precise_mythical_node#data..colcxx . . $ $anonymous_type_6da04880c2c107c6_0#col.;
648 }
649 return v->dimcxx . . $ $anonymous_type_4c10de060a7aee5b_5#dim.;
650 }
651 case NON_SPARSEcxx . . $ NON_SPARSE.:
652 {
653 return vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.;
654 }
655 default:
656 {
657 return v->dimcxx . . $ $anonymous_type_4c10de060a7aee5b_5#dim.;
658 }
659 }
660
661 return v->dimcxx . . $ $anonymous_type_4c10de060a7aee5b_5#dim.;
662
663 }
664
665
666 /*************************************************************************
667 *Move to the previous element in the vector. Sets past_beg and unsets
668 *past_end if appropriate.
669 *
670 *INPUT: v: the vector vit is traversing
671 *
672 *OUTPUT: vit points to the previous element in the vector or is past_beg.
673 *
674 *TIME:
675 * NON_SPARSE: O(1)
676 * SPARSE_ARRAY: O(1)
677 * SPARSE_LIST: O(1)
678 *************************************************************************/
679
680 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_prevcxx . . $ vectorit_prev(e216517ed0835285).(VectorIteratorcxx . . $ VectorIterator# *vit, Vectorcxx . . $ Vector# *v) {
681
682 if (!v || !vit) {
683 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
684 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "vectorit_prev: null arguments.\n");
685 }
686 if (vit) {
687 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = -1;
688 }
689 return;
690 }
691
692 switch (v->typecxx . . $ $anonymous_type_4c10de060a7aee5b_5#type.) {
693 case NON_SPARSEcxx . . $ NON_SPARSE.:
694 case SPARSE_ARRAYcxx . . $ SPARSE_ARRAY.:
695 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.--;
696 return;
697 case SPARSE_LISTcxx . . $ SPARSE_LIST.:
698 if ((v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.)) {
699 if (vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.) {
700 vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr. = vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.->prevcxx . . $ compact_mythical_node#prev.;
701 } else {
702 vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr. = v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.->tailcxx . . $ $anonymous_type_6da04880c2c107c6_8#tail..compactcxx . . $ $anonymous_type_6da04880c2c107c6_7#compact.;
703 }
704 } else {
705 if (vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.) {
706 vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr. = vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.->prevcxx . . $ precise_mythical_node#prev.;
707 } else {
708 vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr. = v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.->tailcxx . . $ $anonymous_type_6da04880c2c107c6_8#tail..precisecxx . . $ $anonymous_type_6da04880c2c107c6_7#precise.;
709 }
710
711 }
712 default:
713 return;
714 }
715 }
716
717 /*************************************************************************
718 *Move to the next element in the vector.
719 *
720 *INPUT: v: the vector vit is traversing
721 *
722 *OUTPUT: vit points to the next element in the vector or is past_end.
723 *
724 *TIME:
725 * NON_SPARSE: O(1)
726 * SPARSE_ARRAY: O(1)
727 * SPARSE_LIST: O(1)
728 *************************************************************************/
729
730 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_nextcxx . . $ vectorit_next(e216517ed0835285).(VectorIteratorcxx . . $ VectorIterator# *vit, Vectorcxx . . $ Vector# *v) {
731 if (!v || !vit) {
732 //if (MATR_DEBUG_MODE) {
733 //fprintf(stderr, "vectorit_next: null arguments.\n");
734 //}
735 return;
736 }
737
738 switch (v->typecxx . . $ $anonymous_type_4c10de060a7aee5b_5#type.) {
739 case NON_SPARSEcxx . . $ NON_SPARSE.:
740 case SPARSE_ARRAYcxx . . $ SPARSE_ARRAY.:
741 vit->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.++;
742 return;
743 case SPARSE_LISTcxx . . $ SPARSE_LIST.:
744 if ((v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.)) {
745 if (vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.) {
746 vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr. = vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.->nextcxx . . $ compact_mythical_node#next.;
747 } else {
748 vit->ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr. = v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.->headcxx . . $ $anonymous_type_6da04880c2c107c6_8#head..compactcxx . . $ $anonymous_type_6da04880c2c107c6_7#compact.;
749 }
750 } else {
751 if (vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.) {
752 vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr. = vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.->nextcxx . . $ precise_mythical_node#next.;
753 } else {
754 vit->pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr. = v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..splistcxx . . $ $anonymous_type_4c10de060a7aee5b_4#splist.->headcxx . . $ $anonymous_type_6da04880c2c107c6_8#head..precisecxx . . $ $anonymous_type_6da04880c2c107c6_7#precise.;
755 }
756
757 }
758 default:
759 return;
760 }
761 }
762
763
764 /*************************************************************************
765 *Checks if an iterator is past the end of the vector.
766 *
767 *INPUT: vit: the iterator
768 * v: the vector vit is traversing
769 *
770 *OUTPUT: 1 if vit is past the end of v, 0 else
771 *
772 *TIME:
773 * NON_SPARSE: O(1)
774 * SPARSE_ARRAY: O(1)
775 * SPARSE_LIST: O(1)
776 *************************************************************************/
777
778 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! int vectorit_past_endcxx . . $ vectorit_past_end(8e262e4b8953a5c6).(VectorIteratorcxx . . $ VectorIterator# vit, Vectorcxx . . $ Vector# *v) {
779 if (!v) {
780 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
781 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "vectorit_past_end: null arguments.\n");
782 }
783 return 1;
784 }
785
786 switch (v->typecxx . . $ $anonymous_type_4c10de060a7aee5b_5#type.) {
787 case SPARSE_ARRAYcxx . . $ SPARSE_ARRAY.:
788 if (!v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray. || vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. > v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->last_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#last_elt. ||
789 v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->first_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#first_elt. > v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->last_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#last_elt.) {
790 return 1;
791 }
792 return 0;
793 case SPARSE_LISTcxx . . $ SPARSE_LIST.:
794 if (v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact. && !vit.ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.) {
795 return 1;
796 }
797 if (!(v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.) && !vit.pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.) {
798 return 1;
799 }
800 return 0;
801 case NON_SPARSEcxx . . $ NON_SPARSE.:
802 if (vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. >= v->dimcxx . . $ $anonymous_type_4c10de060a7aee5b_5#dim.) {
803 return 1;
804 }
805 return 0;
806 default:
807 return 1;
808 }
809 }
810
811 /*************************************************************************
812 *Checks if an iterator is past the beginning of the vector.
813 *
814 *INPUT: vit: the iterator
815 * v: the vector vit is traversing
816 *
817 *OUTPUT: 1 if vit is past the beginning of v, 0 else
818 *
819 *TIME:
820 * NON_SPARSE: O(1)
821 * SPARSE_ARRAY: O(1)
822 * SPARSE_LIST: O(1)
823 *************************************************************************/
824
825 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! int vectorit_past_begcxx . . $ vectorit_past_beg(8e262e4b8953a5c6).(VectorIteratorcxx . . $ VectorIterator# vit, Vectorcxx . . $ Vector# *v) {
826 if (!v) {
827 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
828 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "vectorit_past_end: null arguments.\n");
829 }
830 return 1;
831 }
832
833 switch (v->typecxx . . $ $anonymous_type_4c10de060a7aee5b_5#type.) {
834 case SPARSE_ARRAYcxx . . $ SPARSE_ARRAY.:
835 if (!(v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.) || vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. < v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->first_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#first_elt.
836 || v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->first_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#first_elt. > v->datacxx . . $ $anonymous_type_4c10de060a7aee5b_5#data..sparraycxx . . $ $anonymous_type_4c10de060a7aee5b_4#sparray.->last_eltcxx . . $ $anonymous_type_6da04880c2c107c6_6#last_elt.) {
837 return 1;
838 }
839 return 0;
840 case SPARSE_LISTcxx . . $ SPARSE_LIST.:
841 if (v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact. && !vit.ccurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#ccurr.) {
842 return 1;
843 }
844 if (!(v->compactcxx . . $ $anonymous_type_4c10de060a7aee5b_5#compact.) && !vit.pcurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#pcurr.) {
845 return 1;
846 }
847 return 0;
848 case NON_SPARSEcxx . . $ NON_SPARSE.:
849 if (vit.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. < 0) {
850 return 1;
851 }
852 return 0;
853 default:
854 return 1;
855 }
856 }
857
858 /*************************************************************************
859 *Copy one vector iterator to another.
860 *
861 *INPUT: from: vector iterator to copy from
862 *
863 *OUTPUT: to = from.
864 *
865 *TIME:
866 * NON_SPARSE: O(1)
867 * SPARSE_ARRAY: O(1)
868 * SPARSE_LIST: O(1)
869 *************************************************************************/
870
871 MY_INLINEcxx . . $ `crm_svm_matrix_util.h:56:9`! void vectorit_copycxx . . $ vectorit_copy(164c04d928980008).(VectorIteratorcxx . . $ VectorIterator# from, VectorIteratorcxx . . $ VectorIterator# *to) {
872 if (!to) {
873 if (MATR_DEBUG_MODEcxx . . $ MATR_DEBUG_MODE.) {
874 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "vectorit_copy: null to vector.\n");
875 }
876 return;
877 }
878 to->nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr. = from.nscurrcxx . . $ $anonymous_type_4c10de060a7aee5b_2#nscurr.;
879 }
880
881 #endif //crm_svm_matrix.h