Skip to content

Commit

Permalink
use absoluteLinOp template not concreteLinOp
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Sep 17, 2020
1 parent 28a8bfb commit 42c26f9
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 62 deletions.
3 changes: 2 additions & 1 deletion core/test/base/lin_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ template <typename Type>
class DummyLinOpWithType
: public gko::EnableLinOp<DummyLinOpWithType<Type>>,
public gko::EnableCreateMethod<DummyLinOpWithType<Type>>,
public gko::EnableAbsoluteComputation<DummyLinOpWithType<Type>> {
public gko::EnableAbsoluteComputation<
gko::remove_complex<DummyLinOpWithType<Type>>> {
public:
using absolute_type = gko::remove_complex<DummyLinOpWithType>;
DummyLinOpWithType(std::shared_ptr<const gko::Executor> exec)
Expand Down
15 changes: 7 additions & 8 deletions include/ginkgo/core/base/lin_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ class DiagonalExtractable {

/**
* The AbsoluteComputable is an interface that allows to get the component wise
* absolute of a LinOp. Use EnableAbsoluteComputation<ConcreteLinOp> to
* absolute of a LinOp. Use EnableAbsoluteComputation<AbsoluteLinOp> to
* implement this interface.
*/
class AbsoluteComputable {
Expand All @@ -648,19 +648,18 @@ class AbsoluteComputable {
/**
* The EnableAbsoluteComputation mixin provides the default implementations of
* `compute_absolute_linop` and the absolute interface. `compute_absolute` gets
* a new remove_complex<ConcreteLinOp> which removes the complex value_type by
* applying outplace absolute. `compute_absolute_inplace` applies absolute
* a new AbsoluteLinOp. `compute_absolute_inplace` applies absolute
* inplace, so it still keeps the value_type of the class.
*
* @tparam ConcreteLinOp the concrete LinOp which is being implemented
* @tparam AbsoluteLinOp the absolute LinOp which is being returned
* [CRTP parameter]
*
* @ingroup LinOp
*/
template <typename ConcreteLinOp>
template <typename AbsoluteLinOp>
class EnableAbsoluteComputation : public AbsoluteComputable {
public:
using outplace_type = remove_complex<ConcreteLinOp>;
using absolute_type = AbsoluteLinOp;

virtual ~EnableAbsoluteComputation() = default;

Expand All @@ -670,11 +669,11 @@ class EnableAbsoluteComputation : public AbsoluteComputable {
}

/**
* Gets the absolute ConcreteLinOp
* Gets the AbsoluteLinOp
*
* @return a pointer to the new absolute object
*/
virtual std::unique_ptr<outplace_type> compute_absolute() const = 0;
virtual std::unique_ptr<absolute_type> compute_absolute() const = 0;
};


Expand Down
6 changes: 3 additions & 3 deletions include/ginkgo/core/matrix/coo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class Coo : public EnableLinOp<Coo<ValueType, IndexType>>,
public DiagonalExtractable<ValueType>,
public ReadableFromMatrixData<ValueType, IndexType>,
public WritableToMatrixData<ValueType, IndexType>,
public EnableAbsoluteComputation<Coo<ValueType, IndexType>> {
public EnableAbsoluteComputation<
remove_complex<Coo<ValueType, IndexType>>> {
friend class EnableCreateMethod<Coo>;
friend class EnablePolymorphicObject<Coo, LinOp>;
friend class Csr<ValueType, IndexType>;
Expand All @@ -97,8 +98,7 @@ class Coo : public EnableLinOp<Coo<ValueType, IndexType>>,
using value_type = ValueType;
using index_type = IndexType;
using mat_data = matrix_data<ValueType, IndexType>;
using absolute_type =
typename EnableAbsoluteComputation<Coo>::outplace_type;
using absolute_type = remove_complex<Coo>;

friend class Coo<next_precision<ValueType>, IndexType>;

Expand Down
6 changes: 3 additions & 3 deletions include/ginkgo/core/matrix/csr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ class Csr : public EnableLinOp<Csr<ValueType, IndexType>>,
public WritableToMatrixData<ValueType, IndexType>,
public Transposable,
public Permutable<IndexType>,
public EnableAbsoluteComputation<Csr<ValueType, IndexType>> {
public EnableAbsoluteComputation<
remove_complex<Csr<ValueType, IndexType>>> {
friend class EnableCreateMethod<Csr>;
friend class EnablePolymorphicObject<Csr, LinOp>;
friend class Coo<ValueType, IndexType>;
Expand All @@ -148,8 +149,7 @@ class Csr : public EnableLinOp<Csr<ValueType, IndexType>>,
using index_type = IndexType;
using transposed_type = Csr<ValueType, IndexType>;
using mat_data = matrix_data<ValueType, IndexType>;
using absolute_type =
typename EnableAbsoluteComputation<Csr>::outplace_type;
using absolute_type = remove_complex<Csr>;

class automatical;

Expand Down
52 changes: 26 additions & 26 deletions include/ginkgo/core/matrix/dense.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,31 @@ class SparsityCsr;
* @ingroup LinOp
*/
template <typename ValueType = default_precision>
class Dense : public EnableLinOp<Dense<ValueType>>,
public EnableCreateMethod<Dense<ValueType>>,
public ConvertibleTo<Dense<next_precision<ValueType>>>,
public ConvertibleTo<Coo<ValueType, int32>>,
public ConvertibleTo<Coo<ValueType, int64>>,
public ConvertibleTo<Csr<ValueType, int32>>,
public ConvertibleTo<Csr<ValueType, int64>>,
public ConvertibleTo<Ell<ValueType, int32>>,
public ConvertibleTo<Ell<ValueType, int64>>,
public ConvertibleTo<Hybrid<ValueType, int32>>,
public ConvertibleTo<Hybrid<ValueType, int64>>,
public ConvertibleTo<Sellp<ValueType, int32>>,
public ConvertibleTo<Sellp<ValueType, int64>>,
public ConvertibleTo<SparsityCsr<ValueType, int32>>,
public ConvertibleTo<SparsityCsr<ValueType, int64>>,
public DiagonalExtractable<ValueType>,
public ReadableFromMatrixData<ValueType, int32>,
public ReadableFromMatrixData<ValueType, int64>,
public WritableToMatrixData<ValueType, int32>,
public WritableToMatrixData<ValueType, int64>,
public Transposable,
public Permutable<int32>,
public Permutable<int64>,
public EnableAbsoluteComputation<Dense<ValueType>> {
class Dense
: public EnableLinOp<Dense<ValueType>>,
public EnableCreateMethod<Dense<ValueType>>,
public ConvertibleTo<Dense<next_precision<ValueType>>>,
public ConvertibleTo<Coo<ValueType, int32>>,
public ConvertibleTo<Coo<ValueType, int64>>,
public ConvertibleTo<Csr<ValueType, int32>>,
public ConvertibleTo<Csr<ValueType, int64>>,
public ConvertibleTo<Ell<ValueType, int32>>,
public ConvertibleTo<Ell<ValueType, int64>>,
public ConvertibleTo<Hybrid<ValueType, int32>>,
public ConvertibleTo<Hybrid<ValueType, int64>>,
public ConvertibleTo<Sellp<ValueType, int32>>,
public ConvertibleTo<Sellp<ValueType, int64>>,
public ConvertibleTo<SparsityCsr<ValueType, int32>>,
public ConvertibleTo<SparsityCsr<ValueType, int64>>,
public DiagonalExtractable<ValueType>,
public ReadableFromMatrixData<ValueType, int32>,
public ReadableFromMatrixData<ValueType, int64>,
public WritableToMatrixData<ValueType, int32>,
public WritableToMatrixData<ValueType, int64>,
public Transposable,
public Permutable<int32>,
public Permutable<int64>,
public EnableAbsoluteComputation<remove_complex<Dense<ValueType>>> {
friend class EnableCreateMethod<Dense>;
friend class EnablePolymorphicObject<Dense, LinOp>;
friend class Coo<ValueType, int32>;
Expand All @@ -138,8 +139,7 @@ class Dense : public EnableLinOp<Dense<ValueType>>,
using transposed_type = Dense<ValueType>;
using mat_data = gko::matrix_data<ValueType, int64>;
using mat_data32 = gko::matrix_data<ValueType, int32>;
using absolute_type =
typename EnableAbsoluteComputation<Dense>::outplace_type;
using absolute_type = remove_complex<Dense>;

using row_major_range = gko::range<gko::accessor::row_major<ValueType, 2>>;

Expand Down
24 changes: 12 additions & 12 deletions include/ginkgo/core/matrix/diagonal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ class Dense;
* @ingroup LinOp
*/
template <typename ValueType = default_precision>
class Diagonal : public EnableLinOp<Diagonal<ValueType>>,
public EnableCreateMethod<Diagonal<ValueType>>,
public ConvertibleTo<Csr<ValueType, int32>>,
public ConvertibleTo<Csr<ValueType, int64>>,
public Transposable,
public WritableToMatrixData<ValueType, int32>,
public WritableToMatrixData<ValueType, int64>,
public ReadableFromMatrixData<ValueType, int32>,
public ReadableFromMatrixData<ValueType, int64>,
public EnableAbsoluteComputation<Diagonal<ValueType>> {
class Diagonal
: public EnableLinOp<Diagonal<ValueType>>,
public EnableCreateMethod<Diagonal<ValueType>>,
public ConvertibleTo<Csr<ValueType, int32>>,
public ConvertibleTo<Csr<ValueType, int64>>,
public Transposable,
public WritableToMatrixData<ValueType, int32>,
public WritableToMatrixData<ValueType, int64>,
public ReadableFromMatrixData<ValueType, int32>,
public ReadableFromMatrixData<ValueType, int64>,
public EnableAbsoluteComputation<remove_complex<Diagonal<ValueType>>> {
friend class EnablePolymorphicObject<Diagonal, LinOp>;
friend class EnableCreateMethod<Diagonal>;
friend class Csr<ValueType, int32>;
Expand All @@ -88,8 +89,7 @@ class Diagonal : public EnableLinOp<Diagonal<ValueType>>,
using index_type = int64;
using mat_data = gko::matrix_data<ValueType, int64>;
using mat_data32 = gko::matrix_data<ValueType, int32>;
using absolute_type =
typename EnableAbsoluteComputation<Diagonal>::outplace_type;
using absolute_type = remove_complex<Diagonal>;

std::unique_ptr<LinOp> transpose() const override;

Expand Down
6 changes: 3 additions & 3 deletions include/ginkgo/core/matrix/ell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class Ell : public EnableLinOp<Ell<ValueType, IndexType>>,
public DiagonalExtractable<ValueType>,
public ReadableFromMatrixData<ValueType, IndexType>,
public WritableToMatrixData<ValueType, IndexType>,
public EnableAbsoluteComputation<Ell<ValueType, IndexType>> {
public EnableAbsoluteComputation<
remove_complex<Ell<ValueType, IndexType>>> {
friend class EnableCreateMethod<Ell>;
friend class EnablePolymorphicObject<Ell, LinOp>;
friend class Dense<ValueType>;
Expand All @@ -90,8 +91,7 @@ class Ell : public EnableLinOp<Ell<ValueType, IndexType>>,
using value_type = ValueType;
using index_type = IndexType;
using mat_data = matrix_data<ValueType, IndexType>;
using absolute_type =
typename EnableAbsoluteComputation<Ell>::outplace_type;
using absolute_type = remove_complex<Ell>;

friend class Ell<next_precision<ValueType>, IndexType>;

Expand Down
6 changes: 3 additions & 3 deletions include/ginkgo/core/matrix/hybrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class Hybrid
public DiagonalExtractable<ValueType>,
public ReadableFromMatrixData<ValueType, IndexType>,
public WritableToMatrixData<ValueType, IndexType>,
public EnableAbsoluteComputation<Hybrid<ValueType, IndexType>> {
public EnableAbsoluteComputation<
remove_complex<Hybrid<ValueType, IndexType>>> {
friend class EnableCreateMethod<Hybrid>;
friend class EnablePolymorphicObject<Hybrid, LinOp>;
friend class Dense<ValueType>;
Expand All @@ -94,8 +95,7 @@ class Hybrid
using mat_data = matrix_data<ValueType, IndexType>;
using coo_type = Coo<ValueType, IndexType>;
using ell_type = Ell<ValueType, IndexType>;
using absolute_type =
typename EnableAbsoluteComputation<Hybrid>::outplace_type;
using absolute_type = remove_complex<Hybrid>;


/**
Expand Down
6 changes: 3 additions & 3 deletions include/ginkgo/core/matrix/sellp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class Sellp : public EnableLinOp<Sellp<ValueType, IndexType>>,
public DiagonalExtractable<ValueType>,
public ReadableFromMatrixData<ValueType, IndexType>,
public WritableToMatrixData<ValueType, IndexType>,
public EnableAbsoluteComputation<Sellp<ValueType, IndexType>> {
public EnableAbsoluteComputation<
remove_complex<Sellp<ValueType, IndexType>>> {
friend class EnableCreateMethod<Sellp>;
friend class EnablePolymorphicObject<Sellp, LinOp>;
friend class Dense<ValueType>;
Expand All @@ -87,8 +88,7 @@ class Sellp : public EnableLinOp<Sellp<ValueType, IndexType>>,
using value_type = ValueType;
using index_type = IndexType;
using mat_data = matrix_data<ValueType, IndexType>;
using absolute_type =
typename EnableAbsoluteComputation<Sellp>::outplace_type;
using absolute_type = remove_complex<Sellp>;

friend class Sellp<next_precision<ValueType>, IndexType>;

Expand Down

0 comments on commit 42c26f9

Please sign in to comment.