| 1 | /* WorkvectorPool_def.h |
| 2 | * |
| 3 | * Copyright (C) 2024 David Weenink |
| 4 | * |
| 5 | * This code 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 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code 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 work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #define ooSTRUCTcxx . . $ `dwsys/WorkvectorPool_def.h:19:9`! WorkvectorPool |
| 20 | oo_DEFINE_CLASScxx . . $ `sys/oo.h:176:9`! (WorkvectorPool, Daata) |
| 21 | |
| 22 | oo_INTEGERcxx . . $ `sys/oo.h:45:9`! (poolMemorySize) |
| 23 | oo_VECcxx . . $ `sys/oo.h:74:9`! (memoryPool, poolMemorySize) |
| 24 | oo_INTEGERcxx . . $ `sys/oo.h:45:9`! (numberOfVectors) |
| 25 | oo_INTVECcxx . . $ `sys/oo.h:76:9`! (vectorSizes, numberOfVectors) |
| 26 | oo_INTVECcxx . . $ `sys/oo.h:76:9`! (vectorStart, numberOfVectors) |
| 27 | oo_BOOLVECcxx . . $ `sys/oo.h:78:9`! (inuse, numberOfVectors) |
| 28 | oo_BOOLEANcxx . . $ `sys/oo.h:105:9`! (reusable) |
| 29 | |
| 30 | #if oo_DECLARINGcxx . . $ `sys/oo.h:230:9`! |
| 31 | |
| 32 | VECcxx . . $ VEC# getRawVECcxx . . $ structWorkvectorPool#getRawVEC(98b4eebe06dc2fea). (integercxx . . $ integer# vectorIndex, integercxx . . $ integer# size) { |
| 33 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (vectorIndex > 0 && vectorIndex <= numberOfVectors); |
| 34 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (size <= vectorSizes [vectorIndex]); |
| 35 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (reusable || (! reusable && ! inuse [vectorIndex])); |
| 36 | inusecxx . . $ structWorkvectorPool#inuse. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).vectorIndex] = true; |
| 37 | const integercxx . . $ integer# end = vectorStartcxx . . $ structWorkvectorPool#vectorStart. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).vectorIndex] + size - 1; |
| 38 | return memoryPoolcxx . . $ structWorkvectorPool#memoryPool..partcxx . . $ autovector#part(2d8d48654ca64e70). (vectorStartcxx . . $ structWorkvectorPool#vectorStart. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).vectorIndex], end); |
| 39 | } |
| 40 | |
| 41 | VECcxx . . $ VEC# getZeroVECcxx . . $ structWorkvectorPool#getZeroVEC(98b4eebe06dc2fea). (integercxx . . $ integer# vectorIndex, integercxx . . $ integer# size) { |
| 42 | VECcxx . . $ VEC# result = getRawVECcxx . . $ structWorkvectorPool#getRawVEC(98b4eebe06dc2fea). (vectorIndex, size); |
| 43 | resultcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). <<=cxx . . $ `operator<<=`(c555d170d72ff256). 0.0; |
| 44 | return result; |
| 45 | } |
| 46 | |
| 47 | MATcxx . . $ MAT# getRawMATcxx . . $ structWorkvectorPool#getRawMAT(445c95ea8cc0db18). (integercxx . . $ integer# vectorIndex, integercxx . . $ integer# nrow, integercxx . . $ integer# ncol) { |
| 48 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (vectorIndex > 0 && vectorIndex <= numberOfVectors); |
| 49 | const integercxx . . $ integer# wantedSize = nrow * ncol; |
| 50 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (wantedSize <= vectorSizes [vectorIndex]); |
| 51 | inusecxx . . $ structWorkvectorPool#inuse. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).vectorIndex] = true; |
| 52 | const integercxx . . $ integer# end = vectorStartcxx . . $ structWorkvectorPool#vectorStart. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).vectorIndex] + wantedSize - 1; |
| 53 | VECcxx . . $ VEC# pool = memoryPoolcxx . . $ structWorkvectorPool#memoryPool..partcxx . . $ autovector#part(2d8d48654ca64e70). (vectorStartcxx . . $ structWorkvectorPool#vectorStart. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).vectorIndex], end); |
| 54 | return pool.asmatrixcxx . . $ vector#asmatrix(2dd9a590cd4c0fe2). (nrow, ncol); |
| 55 | } |
| 56 | |
| 57 | MATcxx . . $ MAT# getZeroMATcxx . . $ structWorkvectorPool#getZeroMAT(445c95ea8cc0db18). (integercxx . . $ integer# vectorIndex, integercxx . . $ integer# nrow, integercxx . . $ integer# ncol) { |
| 58 | MATcxx . . $ MAT# result = getRawMATcxx . . $ structWorkvectorPool#getRawMAT(445c95ea8cc0db18). (vectorIndex, nrow, ncol); |
| 59 | resultcxx . . $ matrixview#matrixview(eed9513d24570b3d). <<=cxx . . $ `operator<<=`(50b469ae42a42f64). 0.0; |
| 60 | return result; |
| 61 | } |
| 62 | |
| 63 | void freeVECcxx . . $ structWorkvectorPool#freeVEC(1624ee8275b10bda). (integercxx . . $ integer# vectorIndex) { |
| 64 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (vectorIndex > 0 && vectorIndex <= numberOfVectors); |
| 65 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (inuse [vectorIndex]); |
| 66 | inusecxx . . $ structWorkvectorPool#inuse. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).vectorIndex] = false; |
| 67 | } |
| 68 | |
| 69 | #endif |
| 70 | |
| 71 | oo_END_CLASScxx . . $ `sys/oo.h:186:9`! (WorkvectorPool) |
| 72 | #undef ooSTRUCTcxx . . $ `dwsys/WorkvectorPool_def.h:19:9`! |
| 73 | |
| 74 | /* End of file WorkvectorPool_def.h */ |