Skip to content

Commit

Permalink
Take helper class for index-value pairs outside MatrixHandler sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
pelesh committed Oct 17, 2023
1 parent 23edbf7 commit edc7e4c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 124 deletions.
36 changes: 2 additions & 34 deletions resolve/matrix/MatrixHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <resolve/matrix/Csc.hpp>
#include <resolve/matrix/Csr.hpp>
#include <resolve/workspace/LinAlgWorkspaceFactory.hpp>
#include <resolve/utilities/misc/IndexValuePair.hpp>
#include "MatrixHandler.hpp"
#include "MatrixHandlerCpu.hpp"
#include "MatrixHandlerCuda.hpp"
Expand All @@ -14,39 +15,6 @@ namespace ReSolve {
// Create a shortcut name for Logger static class
using out = io::Logger;

//helper class
indexPlusValue::indexPlusValue()
{
idx_ = 0;
value_ = 0.0;
}


indexPlusValue::~indexPlusValue()
{
}

void indexPlusValue::setIdx(index_type new_idx)
{
idx_ = new_idx;
}

void indexPlusValue::setValue(real_type new_value)
{
value_ = new_value;
}

index_type indexPlusValue::getIdx()
{
return idx_;
}

real_type indexPlusValue::getValue()
{
return value_;
}
//end of helper class

MatrixHandler::MatrixHandler()
{
this->new_matrix_ = true;
Expand Down Expand Up @@ -131,7 +99,7 @@ namespace ReSolve {
index_type* nnz_shifts = new index_type[n];
std::fill_n(nnz_shifts, n , 0);

indexPlusValue* tmp = new indexPlusValue[nnz_unpacked];
IndexValuePair* tmp = new IndexValuePair[nnz_unpacked];

csr_ia[0] = 0;

Expand Down
22 changes: 0 additions & 22 deletions resolve/matrix/MatrixHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,6 @@ namespace ReSolve

namespace ReSolve {

//helper class
class indexPlusValue
{
public:
indexPlusValue();
~indexPlusValue();
void setIdx (index_type new_idx);
void setValue (real_type new_value);

index_type getIdx();
real_type getValue();

bool operator < (const indexPlusValue& str) const
{
return (idx_ < str.idx_);
}

private:
index_type idx_;
real_type value_;
};

class MatrixHandler
{
using vector_type = vector::Vector;
Expand Down
35 changes: 1 addition & 34 deletions resolve/matrix/MatrixHandlerCpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,6 @@ namespace ReSolve {
// Create a shortcut name for Logger static class
using out = io::Logger;

// //helper class
// indexPlusValue::indexPlusValue()
// {
// idx_ = 0;
// value_ = 0.0;
// }


// indexPlusValue::~indexPlusValue()
// {
// }

// void indexPlusValue::setIdx(index_type new_idx)
// {
// idx_ = new_idx;
// }

// void indexPlusValue::setValue(real_type new_value)
// {
// value_ = new_value;
// }

// index_type indexPlusValue::getIdx()
// {
// return idx_;
// }

// real_type indexPlusValue::getValue()
// {
// return value_;
// }
// //end of helper class

MatrixHandlerCpu::MatrixHandlerCpu()
{
// new_matrix_ = true;
Expand Down Expand Up @@ -125,7 +92,7 @@ namespace ReSolve {
// index_type* nnz_shifts = new index_type[n];
// std::fill_n(nnz_shifts, n , 0);

// indexPlusValue* tmp = new indexPlusValue[nnz_unpacked];
// IndexValuePair* tmp = new IndexValuePair[nnz_unpacked];

// csr_ia[0] = 0;

Expand Down
35 changes: 1 addition & 34 deletions resolve/matrix/MatrixHandlerCuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,6 @@ namespace ReSolve {
// Create a shortcut name for Logger static class
using out = io::Logger;

// //helper class
// indexPlusValue::indexPlusValue()
// {
// idx_ = 0;
// value_ = 0.0;
// }


// indexPlusValue::~indexPlusValue()
// {
// }

// void indexPlusValue::setIdx(index_type new_idx)
// {
// idx_ = new_idx;
// }

// void indexPlusValue::setValue(real_type new_value)
// {
// value_ = new_value;
// }

// index_type indexPlusValue::getIdx()
// {
// return idx_;
// }

// real_type indexPlusValue::getValue()
// {
// return value_;
// }
// //end of helper class

MatrixHandlerCuda::MatrixHandlerCuda()
{
// new_matrix_ = true;
Expand Down Expand Up @@ -125,7 +92,7 @@ namespace ReSolve {
// index_type* nnz_shifts = new index_type[n];
// std::fill_n(nnz_shifts, n , 0);

// indexPlusValue* tmp = new indexPlusValue[nnz_unpacked];
// IndexValuePair* tmp = new IndexValuePair[nnz_unpacked];

// csr_ia[0] = 0;

Expand Down
43 changes: 43 additions & 0 deletions resolve/utilities/misc/IndexValuePair.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once


namespace ReSolve {

/// @brief Helper class for COO matrix sorting
class IndexValuePair
{
public:
IndexValuePair() : idx_(0), value_(0.0)
{}
~IndexValuePair()
{}
void setIdx (index_type new_idx)
{
idx_ = new_idx;
}
void setValue (real_type new_value)
{
value_ = new_value;
}

index_type getIdx()
{
return idx_;
}
real_type getValue()
{
return value_;
}

bool operator < (const IndexValuePair& str) const
{
return (idx_ < str.idx_);
}

private:
index_type idx_;
real_type value_;
};

} // namespace ReSolve

0 comments on commit edc7e4c

Please sign in to comment.