// // GlobalMatrix.cpp // HappyHeart // // Created by Sebastien Gilles on 27/04/15. // Copyright (c) 2015 Inria. All rights reserved. // #include "Core/LinearAlgebra/GlobalMatrix.hpp" #include "Core/NumberingSubset.hpp" namespace HappyHeart { GlobalMatrix::GlobalMatrix(const NumberingSubset& row_numbering_subset, const NumberingSubset& col_numbering_subset) : row_numbering_subset_(row_numbering_subset), col_numbering_subset_(col_numbering_subset) { } GlobalMatrix::GlobalMatrix(const GlobalMatrix& rhs) : Parent(rhs), row_numbering_subset_(rhs.row_numbering_subset_), col_numbering_subset_(rhs.col_numbering_subset_) { } void Swap(GlobalMatrix& A, GlobalMatrix& B) { assert(A.GetColNumberingSubset() == B.GetColNumberingSubset()); assert(A.GetRowNumberingSubset() == B.GetRowNumberingSubset()); using Parent = GlobalMatrix::Parent; Swap(static_cast(A), static_cast(B)); } namespace GlobalMatrixNS { bool EqualByNumberingSubset::operator()(const GlobalMatrix& lhs, const GlobalMatrix& rhs) const noexcept { return lhs.GetRowNumberingSubset() == rhs.GetRowNumberingSubset() && lhs.GetColNumberingSubset() == rhs.GetColNumberingSubset(); } bool LessByNumberingSubset::operator()(const GlobalMatrix& lhs, const GlobalMatrix& rhs) const noexcept { const auto& lhs_row_subset = lhs.GetRowNumberingSubset(); const auto& rhs_row_subset = rhs.GetRowNumberingSubset(); if (lhs_row_subset == rhs_row_subset) { return lhs.GetColNumberingSubset() < rhs.GetColNumberingSubset(); } return lhs_row_subset < rhs_row_subset; } FindIfCondition::FindIfCondition(const NumberingSubset& row_numbering_subset, const NumberingSubset& col_numbering_subset) : row_numbering_subset_(row_numbering_subset), col_numbering_subset_(col_numbering_subset) { } bool FindIfCondition::operator()(const GlobalMatrix::unique_ptr& rhs) const noexcept { assert(!(!rhs)); return rhs->GetRowNumberingSubset() == row_numbering_subset_ && rhs->GetColNumberingSubset() == col_numbering_subset_; } } // namespace GlobalMatrixNS } // namespace HappyHeart