Lines Matching full:n
186 PetscDTFactorial - Approximate n! as a real number
189 . n - a non-negative integer
192 . factorial - n!
198 static inline PetscErrorCode PetscDTFactorial(PetscInt n, PetscReal *factorial) in PetscDTFactorial() argument
204 …PetscCheck(n >= 0, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Factorial called with negative numb… in PetscDTFactorial()
205 for (PetscInt i = 1; i < n + 1; ++i) f *= (PetscReal)i; in PetscDTFactorial()
211 PetscDTFactorialInt - Compute n! as an integer
214 . n - a non-negative integer
217 . factorial - n!
222 …This is limited to `n` such that n! can be represented by `PetscInt`, which is 12 if `PetscInt` is…
226 static inline PetscErrorCode PetscDTFactorialInt(PetscInt n, PetscInt *factorial) in PetscDTFactorialInt() argument
232 …n >= 0 && n <= PETSC_FACTORIAL_MAX, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Number of elements… in PetscDTFactorialInt()
233 if (n <= 12) { in PetscDTFactorialInt()
234 *factorial = facLookup[n]; in PetscDTFactorialInt()
239 for (i = 13; i < n + 1; ++i) f *= i; in PetscDTFactorialInt()
246 PetscDTBinomial - Approximate the binomial coefficient `n` choose `k`
249 + n - a non-negative integer
250 - k - an integer between 0 and `n`, inclusive
253 . binomial - approximation of the binomial coefficient `n` choose `k`
259 static inline PetscErrorCode PetscDTBinomial(PetscInt n, PetscInt k, PetscReal *binomial) in PetscDTBinomial() argument
263 …n >= 0 && k >= 0 && k <= n, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Binomial arguments (%" Pet… in PetscDTBinomial()
264 if (n <= 3) { in PetscDTBinomial()
272 *binomial = (PetscReal)binomLookup[n][k]; in PetscDTBinomial()
276 k = PetscMin(k, n - k); in PetscDTBinomial()
277 for (PetscInt i = 0; i < k; i++) binom = (binom * (PetscReal)(n - i)) / (PetscReal)(i + 1); in PetscDTBinomial()
284 PetscDTBinomialInt - Compute the binomial coefficient `n` choose `k`
287 + n - a non-negative integer
288 - k - an integer between 0 and `n`, inclusive
291 . binomial - the binomial coefficient `n` choose `k`
302 static inline PetscErrorCode PetscDTBinomialInt(PetscInt n, PetscInt k, PetscInt *binomial) in PetscDTBinomialInt() argument
308 …n >= 0 && k >= 0 && k <= n, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Binomial arguments (%" Pet… in PetscDTBinomialInt()
309 …eck(n <= PETSC_BINOMIAL_MAX, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Binomial elements %" Pets… in PetscDTBinomialInt()
310 if (n <= 3) { in PetscDTBinomialInt()
318 bin = binomLookup[n][k]; in PetscDTBinomialInt()
322 k = PetscMin(k, n - k); in PetscDTBinomialInt()
323 for (PetscInt i = 0; i < k; i++) binom = (binom * (n - i)) / (i + 1); in PetscDTBinomialInt()
334 …PetscDTEnumPerm - Get a permutation of `n` integers from its encoding into the integers [0, n!) as…
337 + n - a non-negative integer (see note about limits below)
338 - k - an integer in [0, n!)
341 + perm - the permuted list of the integers [0, ..., n-1]
347 …A permutation can be described by the operations that convert the lists [0, 1, ..., n-1] into the …
350 (n - i). This sequence of n-1 differences [d_0, ..., d_{n-2}] is encoded as the number
351 (n-1)! * d_0 + (n-2)! * d_1 + ... + 1! * d_{n-2}.
353 …Limited to `n` such that `n`! can be represented by `PetscInt`, which is 12 if `PetscInt` is a sig…
357 static inline PetscErrorCode PetscDTEnumPerm(PetscInt n, PetscInt k, PetscInt *perm, PeOp PetscBool… in PetscDTEnumPerm() argument
366 …n >= 0 && n <= PETSC_FACTORIAL_MAX, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Number of elements… in PetscDTEnumPerm()
367 if (n >= 2) { in PetscDTEnumPerm()
368 w = &work[n - 2]; in PetscDTEnumPerm()
369 for (i = 2; i <= n; i++) { in PetscDTEnumPerm()
374 for (i = 0; i < n; i++) perm[i] = i; in PetscDTEnumPerm()
375 for (i = 0; i < n - 1; i++) { in PetscDTEnumPerm()
388 …PetscDTPermIndex - Encode a permutation of n into an integer in [0, n!). This inverts `PetscDTEnu…
391 + n - a non-negative integer (see note about limits below)
392 - perm - the permuted list of the integers [0, ..., n-1]
395 + k - an integer in [0, n!)
401 …Limited to `n` such that `n`! can be represented by `PetscInt`, which is 12 if `PetscInt` is a sig…
405 static inline PetscErrorCode PetscDTPermIndex(PetscInt n, const PetscInt *perm, PetscInt *k, PeOp P… in PetscDTPermIndex() argument
415 …n >= 0 && n <= PETSC_FACTORIAL_MAX, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Number of elements… in PetscDTPermIndex()
416 for (i = 0; i < n; i++) work[i] = i; /* partial permutation */ in PetscDTPermIndex()
417 for (i = 0; i < n; i++) iwork[i] = i; /* partial permutation inverse */ in PetscDTPermIndex()
418 for (idx = 0, i = 0; i < n - 1; i++) { in PetscDTPermIndex()
424 idx = idx * (n - i) + diff; in PetscDTPermIndex()
438 …et - Get an ordered subset of the integers [0, ..., n - 1] from its encoding as an integers in [0,…
442 + n - a non-negative integer (see note about limits below)
443 . k - an integer in [0, n]
444 - j - an index in [0, n choose k)
447 . subset - the jth subset of size k of the integers [0, ..., n - 1]
452 Limited by arguments such that `n` choose `k` can be represented by `PetscInt`
456 static inline PetscErrorCode PetscDTEnumSubset(PetscInt n, PetscInt k, PetscInt j, PetscInt *subset) in PetscDTEnumSubset() argument
461 PetscCall(PetscDTBinomialInt(n, k, &Nk)); in PetscDTEnumSubset()
462 for (PetscInt i = 0, l = 0; i < n && l < k; i++) { in PetscDTEnumSubset()
463 PetscInt Nminuskminus = (Nk * (k - l)) / (n - i); in PetscDTEnumSubset()
478 …n ordered subset of k integers from the set [0, ..., n - 1] to its encoding as an integers in [0, …
482 + n - a non-negative integer (see note about limits below)
483 . k - an integer in [0, n]
484 - subset - an ordered subset of the integers [0, ..., n - 1]
492 Limited by arguments such that `n` choose `k` can be represented by `PetscInt`
496 static inline PetscErrorCode PetscDTSubsetIndex(PetscInt n, PetscInt k, const PetscInt *subset, Pet… in PetscDTSubsetIndex() argument
502 PetscCall(PetscDTBinomialInt(n, k, &Nk)); in PetscDTSubsetIndex()
503 for (PetscInt i = 0, l = 0; i < n && l < k; i++) { in PetscDTSubsetIndex()
504 PetscInt Nminuskminus = (Nk * (k - l)) / (n - i); in PetscDTSubsetIndex()
520 …PetscDTEnumSplit - Split the integers [0, ..., n - 1] into two complementary ordered subsets, the …
523 + n - a non-negative integer (see note about limits below)
524 . k - an integer in [0, n]
525 - j - an index in [0, n choose k)
528 + perm - the jth subset of size k of the integers [0, ..., n - 1], followed by its complementary …
534 Limited by arguments such that `n` choose `k` can be represented by `PetscInt`
539 static inline PetscErrorCode PetscDTEnumSplit(PetscInt n, PetscInt k, PetscInt j, PetscInt *perm, P… in PetscDTEnumSplit() argument
546 PetscCall(PetscDTBinomialInt(n, k, &Nk)); in PetscDTEnumSplit()
547 for (i = 0, l = 0, m = 0; i < n && l < k; i++) { in PetscDTEnumSplit()
548 PetscInt Nminuskminus = (Nk * (k - l)) / (n - i); in PetscDTEnumSplit()
561 for (; i < n; i++) subcomp[m++] = i; in PetscDTEnumSplit()