# MatCreateCentering#

Creates a new matrix object that implements the (symmetric and idempotent) centering matrix, I - (1/N) * ones*onesâ€™

## Synopsis#

```
#include "petscmat.h"
PetscErrorCode MatCreateCentering(MPI_Comm comm, PetscInt n, PetscInt N, Mat *C)
```

Collective

## Input Parameters#

MPI communicator**comm -**number of local rows (or**n -**`PETSC_DECIDE`

to have calculated if`N`

is given) This value should be the same as the local size used in creating the y vector for the matrix-vector product y = Ax.number of global rows (or**N -**`PETSC_DETERMINE`

to have calculated if`n`

is given)

## Output Parameter#

the matrix**C -**

## Notes#

The entries of the matrix `C`

are not explicitly stored. Instead, the new matrix
object is a shell that simply performs the action of the centering matrix, i.e.,
multiplying C*x subtracts the mean of the vector x from each of its elements.
This is useful for preserving sparsity when mean-centering the columns of a
matrix is required. For instance, to perform principal components analysis with
a matrix A, the composite matrix C*A can be passed to a partial SVD solver.

## See Also#

## Level#

intermediate

## Location#

src/mat/impls/centering/centering.c

Index of all Mat routines

Table of Contents for all manual pages

Index of all manual pages