Actual source code: vecs.c
1: #include <petscvec.h>
3: PetscErrorCode VecsDestroy(Vecs x)
4: {
5: PetscFunctionBegin;
6: PetscCall(VecDestroy(&(x)->v));
7: PetscCall(PetscFree(x));
8: PetscFunctionReturn(PETSC_SUCCESS);
9: }
11: PetscErrorCode VecsCreateSeq(MPI_Comm comm, PetscInt p, PetscInt m, Vecs *x)
12: {
13: PetscFunctionBegin;
14: PetscCall(PetscNew(x));
15: PetscCall(VecCreateSeq(comm, p * m, &(*x)->v));
16: (*x)->n = m;
17: PetscFunctionReturn(PETSC_SUCCESS);
18: }
20: PetscErrorCode VecsCreateSeqWithArray(MPI_Comm comm, PetscInt p, PetscInt m, PetscScalar *a, Vecs *x)
21: {
22: PetscFunctionBegin;
23: PetscCall(PetscNew(x));
24: PetscCall(VecCreateSeqWithArray(comm, 1, p * m, a, &(*x)->v));
25: (*x)->n = m;
26: PetscFunctionReturn(PETSC_SUCCESS);
27: }
29: PetscErrorCode VecsDuplicate(Vecs x, Vecs *y)
30: {
31: PetscFunctionBegin;
32: PetscCall(PetscNew(y));
33: PetscCall(VecDuplicate(x->v, &(*y)->v));
34: (*y)->n = x->n;
35: PetscFunctionReturn(PETSC_SUCCESS);
36: }