Skip to content

Commit

Permalink
Updated self-destruct matrix class for Eigen is disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
odlomax committed Feb 8, 2024
1 parent 3bfc0c2 commit 53485dc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class ComplexMatrixMultiply {
void applyTwoVector(const array::ArrayView<const Value, Rank>& sourceView,
array::ArrayView<Value, Rank>& targetView) const {
// We could probably optimise contiguous arrays using
// reinterpret_cast<std::complex<double>*>(view.data()). According to the
// C++ standard, this is fine!
// reinterpret_cast<std::complex<double>*>(view.data()). This is fine
// according to the C++ standard!
atlas_omp_parallel_for(auto rowIndex = Size{0};
rowIndex < complexWeightsPtr_->rows(); ++rowIndex) {
auto targetSlice = sliceColumn(targetView, rowIndex);
Expand All @@ -109,8 +109,8 @@ class ComplexMatrixMultiply {

for (auto complexRowIter = complexWeightsPtr_->rowIter(rowIndex);
complexRowIter; ++complexRowIter) {
const auto& colIndex = complexRowIter.col();
const auto& complexWeight = complexRowIter.value();
const auto colIndex = complexRowIter.col();
const auto complexWeight = complexRowIter.value();
const auto sourceSlice = sliceColumn(sourceView, colIndex);

array::helpers::arrayForEachDim(
Expand Down Expand Up @@ -138,9 +138,9 @@ class ComplexMatrixMultiply {

for (auto [complexRowIter, realRowIter] = rowIters(rowIndex);
complexRowIter; ++complexRowIter, ++realRowIter) {
const auto& colIndex = complexRowIter.col();
const auto& complexWeight = complexRowIter.value();
const auto& realWeight = realRowIter.value();
const auto colIndex = complexRowIter.col();
const auto complexWeight = complexRowIter.value();
const auto realWeight = realRowIter.value();
const auto sourceSlice = sliceColumn(sourceView, colIndex);

array::helpers::arrayForEachDim(
Expand All @@ -156,7 +156,7 @@ class ComplexMatrixMultiply {
}
}

/// @brief Return a pair of real and complex row iterators
/// @brief Return a pair of complex and real row iterators
std::pair<ComplexMatrix::RowIter, RealMatrix::RowIter> rowIters(
Size rowIndex) const {
return std::make_pair(complexWeightsPtr_->rowIter(rowIndex),
Expand Down
35 changes: 23 additions & 12 deletions src/atlas/interpolation/method/sphericalvector/SparseMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#pragma once

#include <string>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -64,27 +65,37 @@ class SparseMatrix {
template <typename Value>
class SparseMatrix {
public:
using Index = int;
using Size = long int;

class Triplet {
public:
template <typename... Args>
Triplet(const Args&... args) {}
constexpr Triplet(const Args&... args) {}
};
using Index = int;
using Size = long int;
using Triplets = std::vector<Triplet>;

class RowIter {
public:
template <typename... Args>
constexpr RowIter(const Args&... args) {}
constexpr Index row() const { return Index{}; }
constexpr Index col() const { return Index{}; }
constexpr Value value() const { return Value{}; }
constexpr operator bool() const { return false; }
constexpr RowIter& operator++() { return *this; }
};

template <typename... Args>
SparseMatrix(const Args&... args) {
ATLAS_THROW_EXCEPTION("Atlas has been compiled without Eigen");
throw_Exception("Atlas has been compiled without Eigen", Here());
}
constexpr Size nonZeros() const { return 0; }
constexpr Size rows() const { return 0; }
constexpr Size cols() const { return 0; }
constexpr const Index* outer() { return nullptr; }
constexpr const Index* inner() { return nullptr; }
constexpr const Value* data() { return nullptr; }
SparseMatrix<Value> adjoint() const {
return SparseMatrix<Value>(0, 0, Triplets{});
constexpr Size nonZeros() const { return Size{}; }
constexpr Size rows() const { return Size{}; }
constexpr Size cols() const { return Size{}; }
constexpr RowIter rowIter(Size rowIndex) const { return RowIter{}; }
constexpr SparseMatrix<Value> adjoint() const {
return SparseMatrix<Value>{};
}
};
#endif
Expand Down

0 comments on commit 53485dc

Please sign in to comment.