OMCompiler/SimulationRuntime/c/util/integer_array.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file belongs to the OpenModelica Run-Time System | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings | ||
| 5 | * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights | ||
| 6 | * reserved. | ||
| 7 | * | ||
| 8 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE | ||
| 9 | * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY | ||
| 10 | * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
| 11 | * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL | ||
| 12 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 13 | * | ||
| 14 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License | ||
| 15 | * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs: | ||
| 16 | * http://www.openmodelica.org or https://github.com/OpenModelica/ or | ||
| 17 | * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU | ||
| 18 | * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW | ||
| 19 | * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause. | ||
| 20 | * | ||
| 21 | * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY | ||
| 23 | * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF | ||
| 24 | * OSMC-PL. | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | #ifndef INTEGER_ARRAY_H_ | ||
| 29 | #define INTEGER_ARRAY_H_ | ||
| 30 | |||
| 31 | #include "../openmodelica.h" | ||
| 32 | #include "base_array.h" | ||
| 33 | #include "generic_array.h" | ||
| 34 | #include "../gc/omc_gc.h" | ||
| 35 | #include "omc_msvc.h" | ||
| 36 | #include "index_spec.h" | ||
| 37 | #include <stdarg.h> | ||
| 38 | |||
| 39 | modelica_integer integer_get(const integer_array a, size_t i); | ||
| 40 | modelica_integer integer_get_2D(const integer_array a, size_t i, size_t j); | ||
| 41 | modelica_integer integer_get_3D(const integer_array a, size_t i, size_t j, size_t k); | ||
| 42 | modelica_integer integer_get_4D(const integer_array a, size_t i, size_t j, size_t k, size_t l); | ||
| 43 | modelica_integer integer_get_5D(const integer_array a, size_t i, size_t j, size_t k, size_t l, size_t m); | ||
| 44 | |||
| 45 | /* Settings the fields of a integer_array */ | ||
| 46 | extern void integer_array_create(integer_array *dest, modelica_integer *data, | ||
| 47 | int ndims, ...); | ||
| 48 | |||
| 49 | /* Allocation of a vector */ | ||
| 50 | extern void simple_alloc_1d_integer_array(integer_array* dest, int n); | ||
| 51 | extern void integer_array_ensure_size(integer_array *a, int n); | ||
| 52 | |||
| 53 | /* Allocation of a matrix */ | ||
| 54 | extern void simple_alloc_2d_integer_array(integer_array* dest, int r, int c); | ||
| 55 | |||
| 56 | extern void alloc_integer_array(integer_array *dest,int ndims,...); | ||
| 57 | |||
| 58 | /* Allocation of integer data */ | ||
| 59 | extern void alloc_integer_array_data(integer_array *a); | ||
| 60 | |||
| 61 | /* Frees memory*/ | ||
| 62 | extern void free_integer_array_data(integer_array* a); | ||
| 63 | |||
| 64 | /* Clones data*/ | ||
| 65 | static inline void clone_integer_array_spec(const integer_array * source, | ||
| 66 | integer_array* dest) | ||
| 67 | 55 | { clone_base_array_spec(source, dest); } | |
| 68 | |||
| 69 | /* Copy integer data given memory ptr*/ | ||
| 70 | extern void copy_integer_array_data_mem(const integer_array source, | ||
| 71 | modelica_integer *dest); | ||
| 72 | |||
| 73 | /* Copy integer array*/ | ||
| 74 | extern void copy_integer_array(const integer_array source, integer_array* dest); | ||
| 75 | |||
| 76 | extern void create_integer_array_from_range(integer_array *dest, modelica_integer start, modelica_integer step, modelica_integer stop); | ||
| 77 | |||
| 78 | void fill_integer_array_from_range(integer_array *dest, modelica_integer start, | ||
| 79 | modelica_integer step, modelica_integer stop/*, size_t dim*/); | ||
| 80 | |||
| 81 | extern modelica_integer* calc_integer_index(int ndims, const _index_t* idx_vec, | ||
| 82 | const integer_array * arr); | ||
| 83 | extern modelica_integer* calc_integer_index_va(const integer_array * source,int ndims, | ||
| 84 | va_list ap); | ||
| 85 | |||
| 86 | extern void put_integer_element(modelica_integer value,int i1,integer_array* dest); | ||
| 87 | extern void put_integer_matrix_element(modelica_integer value, int r, int c, | ||
| 88 | integer_array* dest); | ||
| 89 | |||
| 90 | extern void print_integer_matrix(const integer_array * source); | ||
| 91 | extern void print_integer_array(const integer_array * source); | ||
| 92 | |||
| 93 | void integer_vector_to_string(const integer_array *source, modelica_boolean isScalar, char *buffer, size_t bufsize); | ||
| 94 | /* | ||
| 95 | |||
| 96 | a[1:3] := b; | ||
| 97 | |||
| 98 | */ | ||
| 99 | extern void indexed_assign_integer_array(const integer_array source, | ||
| 100 | integer_array* dest, | ||
| 101 | const index_spec_t* dest_spec); | ||
| 102 | extern void simple_indexed_assign_integer_array1(const integer_array * source, | ||
| 103 | int i1, | ||
| 104 | integer_array* dest); | ||
| 105 | extern void simple_indexed_assign_integer_array2(const integer_array * source, | ||
| 106 | int i1, int i2, | ||
| 107 | integer_array* dest); | ||
| 108 | |||
| 109 | /* | ||
| 110 | |||
| 111 | a := b[1:3]; | ||
| 112 | |||
| 113 | */ | ||
| 114 | extern void index_integer_array(const integer_array * source, | ||
| 115 | const index_spec_t* source_spec, | ||
| 116 | integer_array* dest); | ||
| 117 | extern void index_alloc_integer_array(const integer_array * source, | ||
| 118 | const index_spec_t* source_spec, | ||
| 119 | integer_array* dest); | ||
| 120 | |||
| 121 | extern void simple_index_alloc_integer_array1(const integer_array * source,int i1, | ||
| 122 | integer_array* dest); | ||
| 123 | |||
| 124 | extern void simple_index_integer_array1(const integer_array * source, | ||
| 125 | int i1, | ||
| 126 | integer_array* dest); | ||
| 127 | extern void simple_index_integer_array2(const integer_array * source, | ||
| 128 | int i1, int i2, | ||
| 129 | integer_array* dest); | ||
| 130 | |||
| 131 | /* array(A,B,C) for arrays A,B,C */ | ||
| 132 | extern void array_integer_array(integer_array* dest,int n, | ||
| 133 | integer_array first,...); | ||
| 134 | extern void array_alloc_integer_array(integer_array* dest,int n, | ||
| 135 | integer_array first,...); | ||
| 136 | |||
| 137 | /* array(s1,s2,s3) for scalars s1,s2,s3 */ | ||
| 138 | extern void array_scalar_integer_array(integer_array* dest,int n, | ||
| 139 | modelica_integer first,...); | ||
| 140 | extern void array_alloc_scalar_integer_array(integer_array* dest,int n, | ||
| 141 | modelica_integer first,...); | ||
| 142 | |||
| 143 | extern void cat_integer_array(int k,integer_array* dest, int n, | ||
| 144 | const integer_array* first,...); | ||
| 145 | extern void cat_alloc_integer_array(int k,integer_array* dest, int n, | ||
| 146 | const integer_array* first,...); | ||
| 147 | |||
| 148 | extern void range_alloc_integer_array(modelica_integer start, modelica_integer stop, | ||
| 149 | modelica_integer inc,integer_array* dest); | ||
| 150 | extern void range_integer_array(modelica_integer start,modelica_integer stop, | ||
| 151 | modelica_integer inc,integer_array* dest); | ||
| 152 | |||
| 153 | extern integer_array add_alloc_integer_array(const integer_array a, const integer_array b); | ||
| 154 | extern void add_integer_array(const integer_array * a, const integer_array * b, | ||
| 155 | integer_array* dest); | ||
| 156 | |||
| 157 | /* Unary subtraction */ | ||
| 158 | extern void usub_integer_array(integer_array* a); | ||
| 159 | extern void usub_alloc_integer_array(const integer_array a, integer_array* dest); | ||
| 160 | extern void sub_integer_array(const integer_array * a, const integer_array * b, | ||
| 161 | integer_array* dest); | ||
| 162 | extern integer_array sub_alloc_integer_array(const integer_array a, const integer_array b); | ||
| 163 | extern void sub_integer_array_data_mem(const integer_array * a, const integer_array * b, | ||
| 164 | modelica_integer* dest); | ||
| 165 | |||
| 166 | extern void mul_scalar_integer_array(modelica_integer a,const integer_array * b, | ||
| 167 | integer_array* dest); | ||
| 168 | extern integer_array mul_alloc_scalar_integer_array(modelica_integer a,const integer_array b); | ||
| 169 | |||
| 170 | extern void mul_integer_array_scalar(const integer_array * a,modelica_integer b, | ||
| 171 | integer_array* dest); | ||
| 172 | extern void mul_integer_array(const integer_array *a,const integer_array *b,integer_array* dest); | ||
| 173 | extern integer_array mul_alloc_integer_array(const integer_array a, integer_array b); | ||
| 174 | extern integer_array mul_alloc_integer_array_scalar(const integer_array a,modelica_integer b); | ||
| 175 | |||
| 176 | extern modelica_integer mul_integer_scalar_product(const integer_array a, | ||
| 177 | const integer_array b); | ||
| 178 | |||
| 179 | extern void mul_integer_matrix_product(const integer_array *a,const integer_array *b, | ||
| 180 | integer_array*dest); | ||
| 181 | extern void mul_integer_matrix_vector(const integer_array * a, const integer_array * b, | ||
| 182 | integer_array* dest); | ||
| 183 | extern void mul_integer_vector_matrix(const integer_array * a, const integer_array * b, | ||
| 184 | integer_array* dest); | ||
| 185 | extern integer_array mul_alloc_integer_matrix_product_smart(const integer_array a, const integer_array b); | ||
| 186 | |||
| 187 | extern void div_integer_array_scalar(const integer_array * a,modelica_integer b, | ||
| 188 | integer_array* dest); | ||
| 189 | extern integer_array div_alloc_integer_array_scalar(const integer_array a,modelica_integer b); | ||
| 190 | |||
| 191 | extern void division_integer_array_scalar(threadData_t*,const integer_array * a,modelica_integer b, | ||
| 192 | integer_array* dest, const char* division_str); | ||
| 193 | extern integer_array division_alloc_integer_array_scalar(threadData_t *threadData,const integer_array a,modelica_integer b, const char* division_str); | ||
| 194 | extern void div_scalar_integer_array(modelica_integer a, const integer_array* b, integer_array* dest); | ||
| 195 | extern integer_array div_alloc_scalar_integer_array(modelica_integer a, const integer_array b); | ||
| 196 | extern void pow_integer_array_scalar(const integer_array *a, modelica_integer b, integer_array* dest); | ||
| 197 | extern integer_array pow_alloc_integer_array_scalar(const integer_array a, modelica_integer b); | ||
| 198 | |||
| 199 | extern void exp_integer_array(const integer_array * a, modelica_integer n, | ||
| 200 | integer_array* dest); | ||
| 201 | extern integer_array exp_alloc_integer_array(const integer_array a, modelica_integer b); | ||
| 202 | |||
| 203 | extern void promote_integer_array(const integer_array * a, int n,integer_array* dest); | ||
| 204 | extern void promote_scalar_integer_array(modelica_integer s,int n, | ||
| 205 | integer_array* dest); | ||
| 206 | extern void promote_alloc_integer_array(const integer_array * a, int n, | ||
| 207 | integer_array* dest); | ||
| 208 | |||
| 209 | static inline int ndims_integer_array(const integer_array * a) | ||
| 210 | { return ndims_base_array(a); } | ||
| 211 | /* This is defined in integer_array since we return an integer array */ | ||
| 212 | extern void sizes_of_dimensions_base_array(const base_array_t *a, integer_array *dest); | ||
| 213 | |||
| 214 | extern void size_integer_array(const integer_array * a,integer_array* dest); | ||
| 215 | extern modelica_integer scalar_integer_array(const integer_array * a); | ||
| 216 | extern void vector_integer_array(const integer_array * a, integer_array* dest); | ||
| 217 | extern void vector_integer_scalar(modelica_integer a,integer_array* dest); | ||
| 218 | extern void matrix_integer_array(const integer_array * a, integer_array* dest); | ||
| 219 | extern void matrix_integer_scalar(modelica_integer a,integer_array* dest); | ||
| 220 | extern void transpose_integer_array(const integer_array * a, integer_array* dest); | ||
| 221 | extern void transpose_alloc_integer_array(const integer_array * a, integer_array* dest); | ||
| 222 | extern void outer_product_alloc_integer_array(const integer_array * v1,const integer_array * v2, integer_array* dest); | ||
| 223 | extern void outer_product_integer_array(const integer_array * v1,const integer_array * v2, integer_array* dest); | ||
| 224 | extern void fill_alloc_integer_array(integer_array* dest, modelica_integer value, int ndims, ...); | ||
| 225 | extern void identity_integer_array(int n, integer_array* dest); | ||
| 226 | extern void identity_alloc_integer_array(int n, integer_array* dest); | ||
| 227 | |||
| 228 | extern void diagonal_integer_array(const integer_array * v,integer_array* dest); | ||
| 229 | extern void diagonal_alloc_integer_array(const integer_array *v, integer_array* dest); | ||
| 230 | extern void fill_integer_array(integer_array* dest,modelica_integer s); | ||
| 231 | extern void linspace_integer_array(modelica_integer x1,modelica_integer x2,int n, | ||
| 232 | integer_array* dest); | ||
| 233 | extern modelica_integer min_integer_array(const integer_array a); | ||
| 234 | extern modelica_integer max_integer_array(const integer_array a); | ||
| 235 | extern modelica_integer sum_integer_array(const integer_array a); | ||
| 236 | extern modelica_integer product_integer_array(const integer_array a); | ||
| 237 | extern void symmetric_integer_array(const integer_array * a,integer_array* dest); | ||
| 238 | extern void cross_integer_array(const integer_array * x,const integer_array * y,integer_array* dest); | ||
| 239 | extern void cross_alloc_integer_array(const integer_array * x,const integer_array * y,integer_array* dest); | ||
| 240 | extern void skew_integer_array(const integer_array * x,integer_array* dest); | ||
| 241 | |||
| 242 | extern _index_t* integer_array_make_index_array(const integer_array arr); | ||
| 243 | |||
| 244 | static inline void clone_reverse_integer_array_spec(const integer_array * source, | ||
| 245 | integer_array* dest) | ||
| 246 | 78693 | { clone_reverse_base_array_spec(source, dest); } | |
| 247 | extern void convert_alloc_integer_array_to_f77(const integer_array * a, | ||
| 248 | integer_array* dest); | ||
| 249 | extern void convert_alloc_integer_array_from_f77(const integer_array * a, | ||
| 250 | integer_array* dest); | ||
| 251 | |||
| 252 | void pack_integer_array(integer_array *a); | ||
| 253 | void unpack_integer_array(integer_array *a); | ||
| 254 | void pack_alloc_integer_array(integer_array *a, integer_array *dest); | ||
| 255 | void unpack_copy_integer_array(const integer_array *a, integer_array *dest); | ||
| 256 | |||
| 257 | #endif | ||
| 258 |