Skip to main content
`Ctrl`+`K`

# PetscDTBaryToIndex

convert a barycentric coordinate to an index

## Synopsis

    #include "petscdt.h"
    PetscErrorCode PetscDTBaryToIndex(PetscInt len, PetscInt sum, const PetscInt coord[], PetscInt *index)

## Input Parameters

- len - the desired length of the barycentric tuple (usually 1 more than the dimension it represents, so a barycentric coordinate in a triangle has length 3)

- sum - the value that the sum of the barycentric coordinates (which will be non-negative integers) should sum to

- coord - a barycentric coordinate with the given length `len` and `sum`

## Output Parameter

- index - the unique index for the coordinate, >= 0 and < Binomial(len - 1 + sum, sum)

## Note

The indices map to barycentric coordinates in lexicographic order, where the first index is the least significant and the last index is the most significant.

## See Also

`PetscDTIndexToBary`

## Level

beginner

## Location

src/dm/dt/interface/dt.c

Index of all DT routines
Table of Contents for all manual pages
Index of all manual pages