Merged in alexvaillancourt_cmakeInstallPdb (pull request #17)
[ode.git] / include / ode / matrix_coop.h
blob523eeff0222950f64dc3dc0daab2a36f0263f60f
1 /*************************************************************************
2 * *
3 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of EITHER: *
8 * (1) The GNU Lesser General Public License as published by the Free *
9 * Software Foundation; either version 2.1 of the License, or (at *
10 * your option) any later version. The text of the GNU Lesser *
11 * General Public License is included with this library in the *
12 * file LICENSE.TXT. *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
15 * *
16 * This library is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
19 * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
20 * *
21 *************************************************************************/
23 #ifndef _ODE_MATRIX_COOP_H_
24 #define _ODE_MATRIX_COOP_H_
27 #include <ode/common.h>
28 #include <ode/cooperative.h>
29 #include <ode/threading.h>
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 /**
37 * @defgroup matrix_coop Matrix Cooperative Algorithms
39 * Cooperative algorithms operating on matrices and vectors.
41 * @ingroup coop
45 /**
46 * @brief Estimates resource requirements for a @c dCooperativelyFactorLDLT call
48 * The function updates the contents of @a requirements to also suffice for calling
49 * @c dCooperativelyFactorLDLT with the given parameters.
51 * Note: The requirements that could have already been in the @a requirements parameter
52 * are never decreased.
54 * @param requirements The ResourceRequirements object to update
55 * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
56 * @param maximalRowCount Maximal value of rowCount parameter that is going to be used
57 * @ingroup matrix_coop
58 * @see dCooperativelyFactorLDLT
59 * @see dResourceRequirementsCreate
61 ODE_API void dEstimateCooperativelyFactorLDLTResourceRequirements(dResourceRequirementsID requirements,
62 unsigned maximalAllowedThreadCount, unsigned maximalRowCount);
64 /**
65 * @brief Cooperatively factorizes a matrix `A' into L*D*L'
67 * The function factorizes a matrix `A' into L*D*L', where `L' is lower triangular with ones on
68 * the diagonal, and `D' is diagonal.
69 * @a A is a rowCount*rowCount matrix stored by rows, with a leading dimension of @a rowCount rounded
70 * up at least to 4 elements. `L; is written into the strict lower triangle of @a A
71 * (the ones are not written) and the reciprocal of the diagonal elements of `D' are written into @a d.
73 * The @a resources must have had been allocated from a ResourceRequirements object
74 * estimated in @c dEstimateCooperativelyFactorLDLTResourceRequirements.
76 * The operation is performed cooperatively by up to @a allowedThreadCount threads
77 * from thread pool available in @a resources. The threading must not be simultaneously
78 * used (via other @c dResourceContainerID instances) in other calls that employ its features.
80 * @param resources The resources allocated for the function
81 * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
82 * @param A The `A' matrix
83 * @param d The `d' vector
84 * @param rowCount The row count in @a A and @a d
85 * @param rowskip The actual number of elements to be added to skip to next row in @a A
86 * @ingroup matrix_coop
87 * @see dEstimateCooperativelyFactorLDLTResourceRequirements
88 * @see dResourceContainerAcquire
89 * @see dCooperativelySolveLDLT
91 ODE_API void dCooperativelyFactorLDLT(dResourceContainerID resources, unsigned allowedThreadCount,
92 dReal *A, dReal *d, unsigned rowCount, unsigned rowSkip);
95 /**
96 * @brief Estimates resource requirements for a @c dCooperativelySolveLDLT call
98 * The function updates the contents of @a requirements to also suffice for calling
99 * @c dCooperativelySolveLDLT with the given parameters.
101 * Note: The requirements that could have already been in the @a requirements parameter
102 * are never decreased.
104 * @param requirements The ResourceRequirements object to update
105 * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
106 * @param maximalRowCount Maximal value of rowCount parameter that is going to be used
107 * @ingroup matrix_coop
108 * @see dCooperativelySolveLDLT
109 * @see dResourceRequirementsCreate
111 ODE_API void dEstimateCooperativelySolveLDLTResourceRequirements(dResourceRequirementsID requirements,
112 unsigned maximalAllowedThreadCount, unsigned maximalRowCount);
115 * @brief Cooperatively solves L*D*L'*x=b
117 * Given `L', a rowCount*rowCount lower triangular matrix with ones on the diagonal,
118 * and `d', a rowCount*1 vector of the reciprocal diagonal elements of a rowCount*rowCount matrix
119 * D, the function solves L*D*L'*x=b where `x' and `b' are rowCount*1.
120 * The leading dimension of @a L is @a rowSkip. The resulting vector `x' overwrites @a b.
122 * The @a resources must have had been allocated from a ResourceRequirements object
123 * estimated in @c dEstimateCooperativelySolveLDLTResourceRequirements.
125 * The operation is performed cooperatively by up to @a allowedThreadCount threads
126 * from thread pool available in @a resources. The threading must not be simultaneously
127 * used (via other @c dResourceContainerID instances) in other calls that employ its features.
129 * @param resources The resources allocated for the function
130 * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
131 * @param L The `L' matrix
132 * @param d The `d' vector
133 * @param b The `b' vector; also the result is stored here
134 * @param rowCount The row count in @a L, @a d and @a b
135 * @param rowskip The actual number of elements to be added to skip to next row in @a L
136 * @ingroup matrix_coop
137 * @see dEstimateCooperativelySolveLDLTResourceRequirements
138 * @see dResourceContainerAcquire
139 * @see dCooperativelyFactorLDLT
141 ODE_API void dCooperativelySolveLDLT(dResourceContainerID resources, unsigned allowedThreadCount,
142 const dReal *L, const dReal *d, dReal *b, unsigned rowCount, unsigned rowSkip);
146 * @brief Estimates resource requirements for a @c dCooperativelySolveL1Straight call
148 * The function updates the contents of @a requirements to also suffice for calling
149 * @c dCooperativelySolveL1Straight with the given parameters.
151 * Note: The requirements that could have already been in the @a requirements parameter
152 * are never decreased.
154 * @param requirements The ResourceRequirements object to update
155 * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
156 * @param maximalRowCount Maximal value of rowCount parameter that is going to be used
157 * @ingroup matrix_coop
158 * @see dCooperativelySolveL1Straight
159 * @see dResourceRequirementsCreate
161 ODE_API void dEstimateCooperativelySolveL1StraightResourceRequirements(dResourceRequirementsID requirements,
162 unsigned maximalAllowedThreadCount, unsigned maximalRowCount);
165 * @brief Cooperatively solves L*x=b
167 * The function solves L*x=b, where `L' is rowCount*rowCount lower triangular with ones on the diagonal,
168 * and `x', `b' are rowCount*1. The leading dimension of @a L is @a rowSkip.
169 * @a b is overwritten with `x'.
171 * The @a resources must have had been allocated from a ResourceRequirements object
172 * estimated in @c dEstimateCooperativelySolveL1StraightResourceRequirements.
174 * The operation is performed cooperatively by up to @a allowedThreadCount threads
175 * from thread pool available in @a resources. The threading must not be simultaneously
176 * used (via other @c dResourceContainerID instances) in other calls that employ its features.
178 * @param resources The resources allocated for the function
179 * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
180 * @param L The `L' matrix
181 * @param b The `b' vector; also the result is stored here
182 * @param rowCount The row count in @a L and @a b
183 * @param rowskip The actual number of elements to be added to skip to next row in @a L
184 * @ingroup matrix_coop
185 * @see dEstimateCooperativelySolveL1StraightResourceRequirements
186 * @see dResourceContainerAcquire
187 * @see dCooperativelyFactorLDLT
189 ODE_API void dCooperativelySolveL1Straight(dResourceContainerID resources, unsigned allowedThreadCount,
190 const dReal *L, dReal *b, unsigned rowCount, unsigned rowSkip);
194 * @brief Estimates resource requirements for a @c dCooperativelySolveL1Transposed call
196 * The function updates the contents of @a requirements to also suffice for calling
197 * @c dCooperativelySolveL1Transposed with the given parameters.
199 * Note: The requirements that could have already been in the @a requirements parameter
200 * are never decreased.
202 * @param requirements The ResourceRequirements object to update
203 * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
204 * @param maximalRowCount Maximal value of rowCount parameter that is going to be used
205 * @ingroup matrix_coop
206 * @see dCooperativelySolveL1Transposed
207 * @see dResourceRequirementsCreate
209 ODE_API void dEstimateCooperativelySolveL1TransposedResourceRequirements(dResourceRequirementsID requirements,
210 unsigned maximalAllowedThreadCount, unsigned maximalRowCount);
213 * @brief Cooperatively solves L'*x=b
215 * The function solves L'*x=b, where `L' is rowCount*rowCount lower triangular with ones on the diagonal,
216 * and `x', b are rowCount*1. The leading dimension of @a L is @a rowSkip.
217 * @a b is overwritten with `x'.
219 * The @a resources must have had been allocated from a ResourceRequirements object
220 * estimated in @c dEstimateCooperativelySolveL1TransposedResourceRequirements.
222 * The operation is performed cooperatively by up to @a allowedThreadCount threads
223 * from thread pool available in @a resources. The threading must not be simultaneously
224 * used (via other @c dResourceContainerID instances) in other calls that employ its features.
226 * @param resources The resources allocated for the function
227 * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
228 * @param L The `L' matrix
229 * @param b The `b' vector; also the result is stored here
230 * @param rowCount The row count in @a L and @a b
231 * @param rowskip The actual number of elements to be added to skip to next row in @a L
232 * @ingroup matrix_coop
233 * @see dEstimateCooperativelySolveL1TransposedResourceRequirements
234 * @see dResourceContainerAcquire
235 * @see dCooperativelyFactorLDLT
237 ODE_API void dCooperativelySolveL1Transposed(dResourceContainerID resources, unsigned allowedThreadCount,
238 const dReal *L, dReal *b, unsigned rowCount, unsigned rowSkip);
242 * @brief Estimates resource requirements for a @c dCooperativelyScaleVector call
244 * The function updates the contents of @a requirements to also suffice for calling
245 * @c dCooperativelyScaleVector with the given parameters.
247 * Note: The requirements that could have already been in the @a requirements parameter
248 * are never decreased.
250 * @param requirements The ResourceRequirements object to update
251 * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
252 * @param maximalElementCount Maximal value of elementCount parameter that is going to be used
253 * @ingroup matrix_coop
254 * @see dCooperativelyScaleVector
255 * @see dResourceRequirementsCreate
257 ODE_API void dEstimateCooperativelyScaleVectorResourceRequirements(dResourceRequirementsID requirements,
258 unsigned maximalAllowedThreadCount, unsigned maximalElementCount);
261 * @brief Multiplies elements of one vector by corresponding element of another one
263 * In matlab syntax, the operation performed is: dataVector(1:elementCount) = dataVector(1:elementCount) .* scaleVector(1:elementCount)
265 * The @a resources must have had been allocated from a ResourceRequirements object
266 * estimated in @c dEstimateCooperativelyScaleVectorResourceRequirements.
268 * The operation is performed cooperatively by up to @a allowedThreadCount threads
269 * from thread pool available in @a resources. The threading must not be simultaneously
270 * used (via other @c dResourceContainerID instances) in other calls that employ its features.
272 * @param resources The resources allocated for the function
273 * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
274 * @param dataVector The vector to be scaled in place
275 * @param scaleVector The scale vector
276 * @param elementCount The number of elements in @a dataVector and @a scaleVector
277 * @ingroup matrix_coop
278 * @see dEstimateCooperativelyScaleVectorResourceRequirements
279 * @see dResourceContainerAcquire
280 * @see dCooperativelyFactorLDLT
282 ODE_API void dCooperativelyScaleVector(dResourceContainerID resources, unsigned allowedThreadCount,
283 dReal *dataVector, const dReal *scaleVector, unsigned elementCount);
286 #ifdef __cplusplus
287 } // extern "C"
288 #endif
291 #endif // #ifndef _ODE_MATRIX_COOP_H_