OpenMEEG
matop.h
Go to the documentation of this file.
1 // Project Name: OpenMEEG (http://openmeeg.github.io)
2 // © INRIA and ENPC under the French open source license CeCILL-B.
3 // See full copyright notice in the file LICENSE.txt
4 // If you make a copy of this file, you must either:
5 // - provide also LICENSE.txt and modify this header to refer to it.
6 // - replace this header by the LICENSE.txt content.
7 
8 #pragma once
9 
10 #include "matrix.h"
11 #include "sparse_matrix.h"
12 
13 namespace OpenMEEG {
14 
15  inline Matrix
17  const size_t Nl = M.nlin();
18  const size_t Nc = M.ncol();
19 
20  Matrix U,V;
21  SparseMatrix D;
22  M.svd(U,D,V);
23 
24  // Set S to 0 everywhere, except in the last part of the diag:
25 
26  SparseMatrix S(Nc,Nc);
27  for (unsigned i=Nl;i<Nc;++i)
28  S(i,i) = 1.0;
29 
30  return (V.transpose()*S)*V; // P is a projector: P^2 = P and mat*P*X = 0
31  }
32 }
Dimension nlin() const
Definition: linop.h:48
virtual Dimension ncol() const
Definition: linop.h:51
Matrix class Matrix class.
Definition: matrix.h:28
void svd(Matrix &U, SparseMatrix &S, Matrix &V, const bool complete=true) const
Matrix transpose() const
Matrix nullspace_projector(const Matrix &M)
Definition: matop.h:16