/*
 * Copyright (C) 2008-2012 Delft University of Technology - All rights reserved.
 *
 * Author: Reijer Idema
 */

/**
 * @file PetscVecSeq.h
 * PetscVecSeq header.
 * Provides some PETSc vector operations for VECSEQ vectors,
 * that benefit from being pulled out of the PETSc framework.
 * These benefits are generally const correctness and/or speed.
 */
#ifndef PetscUtils_PetscVecSeq_h
#define PetscUtils_PetscVecSeq_h

#include "petscvec.h"
#include "PetscUtils.def"

PETSCUTILS_NAMESPACE_BEGIN

typedef const _p_Vec* ConstVec;		///< Constant PETSc vector type.

/**
 * Gets the number of elements in a vector.
 * Const version of the PETSc function VecGetSize().
 * @param vec vector.
 * @return number of elements.
 */
PetscInt VecSeqGetSize(ConstVec vec);

/**
 * Gets a pointer to the data in a PETSc vector of type VECSEQ.
 * Const version of the PETSc function VecGetArray().
 * @param[in] vec PETSc vector of type VECSEQ.
 * @param[out] a pointer to the vector value array.
 * @return error code, 0 if there was no error.
 */
PetscErrorCode VecSeqGetArray(ConstVec vec, const PetscScalar *a[]);

/**
 * Restores a PETSc vector of type VECSEQ after a call to VecSeqGetArray().
 * Const version of the PETSc function VecRestoreArray().
 * @param[in] vec PETSc vector of type VECSEQ.
 * @param[out] a pointer to the vector value array.
 * @return error code, 0 if there was no error.
 */
PetscErrorCode VecSeqRestoreArray(ConstVec vec, const PetscScalar *a[]);

/**
 * Prints a vector of type VECSEQ to the standard output.
 * Const version of the PETSc function VecView().
 * @param[in] vec PETSc vector of type VECSEQ.
 * @return error code, 0 if there was no error.
 */
PetscErrorCode VecSeqView(ConstVec vec);

PETSCUTILS_NAMESPACE_END

#endif // PetscUtils_PetscVecSeq_h
