@@ -100,7 +100,7 @@ namespace alp {
100100 }
101101
102102 template < typename D >
103- void setInitialized ( alp::internal::Matrix< D, reference > & A, bool initialized ) noexcept {
103+ void setInitialized ( alp::internal::Matrix< D, reference > & A, const bool initialized ) noexcept {
104104 A.initialized = initialized;
105105 }
106106
@@ -145,7 +145,7 @@ namespace alp {
145145 friend const bool & internal::getInitialized ( const alp::internal::Matrix< DataType, reference > & ) noexcept ;
146146
147147 template < typename DataType >
148- friend void internal::setInitialized ( alp::internal::Matrix< DataType, reference > & , bool ) noexcept ;
148+ friend void internal::setInitialized ( alp::internal::Matrix< DataType, reference > & , const bool ) noexcept ;
149149
150150 typedef Matrix< D, reference > self_type;
151151
@@ -392,21 +392,11 @@ namespace alp {
392392 template < typename DerivedMatrix >
393393 std::pair< size_t , size_t > dims ( const MatrixBase< DerivedMatrix > & A ) noexcept ;
394394
395- // template< typename DerivedMatrix >
396- // bool getInitialized( MatrixBase< DerivedMatrix > & ) noexcept;
397-
398- // template< typename DerivedMatrix >
399- // void getInitialized( MatrixBase< DerivedMatrix > &, bool ) noexcept;
400-
401- template < typename T, typename Structure, enum Density density, typename View, typename ImfR, typename ImfC >
402- bool getInitialized ( const alp::Matrix< T, Structure, density, View, ImfR, ImfC, reference > & A ) noexcept {
403- return internal::getInitialized ( internal::getContainer ( A ) );
404- }
395+ template < typename MatrixType >
396+ bool getInitialized ( const MatrixType &A ) noexcept ;
405397
406- template < typename T, typename Structure, enum Density density, typename View, typename ImfR, typename ImfC >
407- void setInitialized ( alp::Matrix< T, Structure, density, View, ImfR, ImfC, reference > & A, bool initialized ) noexcept {
408- internal::setInitialized ( internal::getContainer ( A ), initialized );
409- }
398+ template < typename MatrixType >
399+ void setInitialized ( MatrixType &, const bool ) noexcept ;
410400
411401 } // namespace internal
412402
@@ -439,6 +429,12 @@ namespace alp {
439429
440430 friend std::pair< size_t , size_t > dims<>( const MatrixBase< DerivedMatrix > &A ) noexcept ;
441431
432+ template < typename MatrixType >
433+ friend bool getInitialized ( const MatrixType &A ) noexcept ;
434+
435+ template < typename MatrixType >
436+ friend void setInitialized ( MatrixType &A, const bool initialized ) noexcept ;
437+
442438 protected:
443439
444440 std::pair< size_t , size_t > dims () const noexcept {
@@ -454,6 +450,15 @@ namespace alp {
454450 template < typename MatrixType >
455451 friend typename MatrixType::storage_index_type getStorageIndex ( const MatrixType &A, const size_t i, const size_t j, const size_t s, const size_t P );
456452
453+ bool getInitialized () const {
454+ return static_cast < const DerivedMatrix & >( *this ).getInitialized ();
455+ }
456+
457+ void setInitialized ( const bool initialized ) {
458+ static_cast < DerivedMatrix & >( *this ).setInitialized ( initialized );
459+
460+ }
461+
457462 template < typename AccessType, typename StorageIndexType >
458463 const AccessType access ( const StorageIndexType storageIndex ) const {
459464 static_assert ( std::is_same< AccessType, typename DerivedMatrix::access_type >::value );
@@ -557,13 +562,13 @@ namespace alp {
557562 return A.container ;
558563 }
559564
560- // friend bool getInitialized( self_type & A ) noexcept {
561- // return getInitialized( getContainer( A ) );
562- // }
565+ bool getInitialized () const noexcept {
566+ return internal:: getInitialized ( container );
567+ }
563568
564- // friend void setInitialized( self_type & A, bool initialized ) noexcept {
565- // setInitialized( getContainer( A ) , initialized );
566- // }
569+ void setInitialized ( const bool initialized ) noexcept {
570+ internal:: setInitialized ( container , initialized );
571+ }
567572
568573 /* *
569574 * Returns a constant reference to the element corresponding to
@@ -640,12 +645,23 @@ namespace alp {
640645 typedef std::pair< size_t , size_t > storage_index_type;
641646
642647 protected:
648+
649+ const bool initialized; // Temporary solution, proper implementation pending
650+
643651 ImfR imf_r;
644652 ImfC imf_c;
645653
646654 typedef std::function< Ret( Args... ) > lambda_function_type;
647655 lambda_function_type λ
648656
657+ bool getInitialized () const noexcept {
658+ return initialized;
659+ }
660+
661+ void setInitialized ( const bool ) noexcept {
662+ static_assert ( " Calling setInitialized on a MatrixFunctor is not allowed." );
663+ }
664+
649665 access_type access ( const storage_index_type &storage_index ) const {
650666 return lambda ( imf_r.map ( storage_index.first ), imf_c.map ( storage_index.second ) );
651667 }
@@ -659,11 +675,13 @@ namespace alp {
659675 public:
660676
661677 MatrixFunctor (
678+ const bool initialized,
662679 lambda_function_type &lambda,
663680 ImfR &&imf_r,
664681 ImfC &&imf_c
665682 ) :
666683 MatrixBase< MatrixFunctor< T, ImfR, ImfC, Ret, Args... > >( imf_r.N, imf_c.N ),
684+ initialized ( initialized ),
667685 lambda ( lambda ) {}
668686
669687 }; // class MatrixFunctor
@@ -1645,6 +1663,16 @@ namespace alp {
16451663 /* * Definitions of previously declared global methods that operate on ALP Matrix */
16461664 namespace internal {
16471665
1666+ template < typename MatrixType >
1667+ bool getInitialized ( const MatrixType &A ) noexcept {
1668+ return static_cast < const MatrixBase< typename MatrixType::base_type > >( A ).template getInitialized ();
1669+ }
1670+
1671+ template < typename MatrixType >
1672+ void setInitialized ( MatrixType &A, const bool initialized ) noexcept {
1673+ return static_cast < MatrixBase< typename MatrixType::base_type > >( A ).template setInitialized ( initialized );
1674+ }
1675+
16481676 template < typename DerivedMatrix >
16491677 std::pair< size_t , size_t > dims ( const MatrixBase< DerivedMatrix > & A ) noexcept {
16501678 return A.dims ();
0 commit comments