OpenMS
MatrixUtils.h
Go to the documentation of this file.
1// Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Christian Ehrlich $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12
13#include <Eigen/Core>
14
15#include <boost/shared_ptr.hpp>
16
17namespace OpenMS
18{
23 typedef boost::shared_ptr< const Eigen::MatrixXd > EigenMatrixXdPtr;
24 typedef boost::shared_ptr< Eigen::MatrixXd > MutableEigenMatrixXdPtr;
25
26 inline EigenMatrixXdPtr
28 {
30 for (unsigned i=0; i<m.rows(); ++i)
31 {
32 for (unsigned j=0; j<m.cols(); ++j)
33 {
34 (*em)(i,j) = m(i,j);
35 }
36 }
37 return em;
38 }
39
40 inline bool
41 matrixIsIdentityMatrix(const Matrix<double>& channel_frequency)
42 {
43 for (Matrix<double>::SizeType i = 0; i < channel_frequency.rows(); ++i)
44 {
45 for (Matrix<double>::SizeType j = 0; j < channel_frequency.rows(); ++j)
46 {
47 // check if the entries are those of a identity matrix;
48 // i==j -> m(i,j) == 1.0 && i!=j -> m(i,j) == 0.0
49 if ((i == j && channel_frequency(i, j) != 1.0) || channel_frequency(i, j) != 0.0)
50 {
51 return false;
52 }
53 }
54 }
55 return true;
56 }
57}//namespace
58
SizeType rows() const
Number of rows.
Definition: Matrix.h:232
SizeType cols() const
Number of columns.
Definition: Matrix.h:238
Definition: IsobaricIsotopeCorrector.h:17
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
boost::shared_ptr< Eigen::MatrixXd > MutableEigenMatrixXdPtr
Definition: MatrixUtils.h:24
boost::shared_ptr< const Eigen::MatrixXd > EigenMatrixXdPtr
Definition: MatrixUtils.h:23
bool matrixIsIdentityMatrix(const Matrix< double > &channel_frequency)
Definition: MatrixUtils.h:41
EigenMatrixXdPtr convertOpenMSMatrix2EigenMatrixXd(const Matrix< double > &m)
Definition: MatrixUtils.h:27