LCOV - code coverage report
Current view: top level - source - MatrixOperator.cpp (source / functions) Hit Total Coverage
Test: LibForBES Unit Tests Lines: 26 28 92.9 %
Date: 2016-04-18 Functions: 9 10 90.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* 
       2             :  * File:   MatrixOperator.cpp
       3             :  * Author: Pantelis Sopasakis
       4             :  * 
       5             :  * Created on July 24, 2015, 7:31 PM
       6             :  * 
       7             :  * ForBES is free software: you can redistribute it and/or modify
       8             :  * it under the terms of the GNU Lesser General Public License as published by
       9             :  * the Free Software Foundation, either version 3 of the License, or
      10             :  * (at your option) any later version.
      11             :  *  
      12             :  * ForBES is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      15             :  * GNU Lesser General Public License for more details.
      16             :  * 
      17             :  * You should have received a copy of the GNU Lesser General Public License
      18             :  * along with ForBES. If not, see <http://www.gnu.org/licenses/>.
      19             :  */
      20             : 
      21             : #include "MatrixOperator.h"
      22             : 
      23           0 : Matrix& MatrixOperator::getMatrix() const {
      24           0 :     return m_A;
      25             : }
      26             : 
      27       57753 : bool MatrixOperator::isSelfAdjoint() {
      28       57753 :     return m_isSelfAdjoint;
      29             : }
      30             : 
      31           2 : void MatrixOperator::setMatrix(Matrix& A) {
      32           2 :     this->m_A = A;
      33           2 :     m_isSelfAdjoint = (A.getNrows() == A.getNcols() && A.isSymmetric());
      34           2 : }
      35             : 
      36          34 : MatrixOperator::MatrixOperator(Matrix& A) : m_A(A) {
      37          34 :     if (A.isSymmetric()) {
      38           9 :         this->m_isSelfAdjoint = true;
      39             :     } else {
      40          25 :         this->m_isSelfAdjoint = false;
      41             :     }
      42          34 : }
      43             : 
      44          48 : MatrixOperator::~MatrixOperator() {
      45          48 : }
      46             : 
      47       57922 : int MatrixOperator::call(Matrix& y, double alpha, Matrix& x, double gamma) {
      48       57922 :     return Matrix::mult(y, alpha, m_A, x, gamma);
      49             : }
      50             : 
      51       57745 : int MatrixOperator::callAdjoint(Matrix& y, double alpha, Matrix& x, double gamma) {
      52       57745 :     if (isSelfAdjoint()) {
      53           1 :         return call(y, alpha, x, gamma);
      54             :     }
      55       57744 :     m_A.transpose();
      56       57744 :     int status = Matrix::mult(y, alpha, m_A, x, gamma);    
      57       57744 :     m_A.transpose();
      58       57744 :     return status;
      59             : }
      60             : 
      61      115502 : std::pair<size_t, size_t> MatrixOperator::dimensionIn() {
      62      115502 :     return _VECTOR_OP_DIM(m_A.getNcols());
      63             : }
      64             : 
      65      115879 : std::pair<size_t, size_t> MatrixOperator::dimensionOut() {
      66      115879 :     return _VECTOR_OP_DIM(m_A.getNrows());
      67             : }
      68             : 
      69             : 

Generated by: LCOV version 1.10