add comment header to include/array files
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Christian Zimmermann 2023-11-05 16:27:36 +01:00
parent c055ef39da
commit 7487929bfc
12 changed files with 110 additions and 162 deletions

View file

@ -1,3 +1,14 @@
// -*- C++ -*-
/**
@file include/array/aindex.cc.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_aindex_cc_h__ #ifndef __cxz_aindex_cc_h__
#define __cxz_aindex_cc_h__ #define __cxz_aindex_cc_h__

View file

@ -1,3 +1,14 @@
// -*- C++ -*-
/**
@file include/array/aindex.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_aindex_h__ #ifndef __cxz_aindex_h__
#define __cxz_aindex_h__ #define __cxz_aindex_h__

View file

@ -1,6 +1,16 @@
// -*- C++ -*-
/**
@file include/array/array.cc.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#include "array_base.cc.h" #include "array_base.cc.h"
#include "marray.cc.h" #include "marray.cc.h"
#include "aindex.cc.h" #include "aindex.cc.h"
#include "slice.cc.h" #include "slice.cc.h"
//#include "functional_array.cc.h"

View file

@ -1,8 +1,18 @@
// -*- C++ -*-
/**
@file include/array/array.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#include "array_base.h" #include "array_base.h"
#include "marray.h" #include "marray.h"
#include "aindex.h" #include "aindex.h"
#include "slice.h" #include "slice.h"
//#include "functional_array.h"
#include "array.cc.h" #include "array.cc.h"

View file

@ -1,3 +1,14 @@
// -*- C++ -*-
/**
@file include/array/array_base.cc.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_array_base_cc_h__ #ifndef __cxz_array_base_cc_h__
#define __cxz_array_base_cc_h__ #define __cxz_array_base_cc_h__

View file

@ -1,3 +1,14 @@
// -*- C++ -*-
/**
@file include/array/array_base.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_array_base_h__ #ifndef __cxz_array_base_h__
#define __cxz_array_base_h__ #define __cxz_array_base_h__

View file

@ -1,99 +0,0 @@
#include "functional_array.h"
namespace CNORXZ
{
/****************************
* FunctionalArray *
****************************/
template <typename T, class Function, class... SRanges>
FunctionalArray<T,Function,SRanges...>::FunctionalArray(const std::shared_ptr<SRanges>&... ranges,
const std::shared_ptr<Function>& func) :
ArrayBase<T,SRanges...>(ranges...), mFunc(func) {}
template <typename T, class Function, class... SRanges>
FunctionalArray<T,Function,SRanges...>::FunctionalArray(const std::shared_ptr<SRanges>&... ranges) :
ArrayBase<T,SRanges...>(ranges...) {}
template <typename T, class Function, class... SRanges>
FunctionalArray<T,Function,SRanges...>::FunctionalArray(const typename CRange::Space& space) :
ArrayBase<T,SRanges...>(space) {}
template <typename T, class Function, class... SRanges>
FunctionalArray<T,Function,SRanges...>::FunctionalArray(const typename CRange::Space& space,
const std::shared_ptr<Function>& func) :
ArrayBase<T,SRanges...>(space), mFunc(func) {}
template <typename T, class Function, class... SRanges>
const T& FunctionalArray<T,Function,SRanges...>::operator[](const IndexType& i) const
{
if constexpr(Function::FISSTATIC){
mVal = Function::apply(i.meta());
}
else {
mVal = (*mFunc)(i.meta());
}
return mVal;
}
template <typename T, class Function, class... SRanges>
const T& FunctionalArray<T,Function,SRanges...>::at(const typename CRange::IndexType::MetaType& meta) const
{
if constexpr(Function::FISSTATIC){
mVal = Function::apply(meta);
}
else {
mVal = (*mFunc)(meta);
}
return mVal;
}
template <typename T, class Function, class... SRanges>
const T* FunctionalArray<T,Function,SRanges...>::data() const
{
return &mVal;
}
template <typename T, class Function, class... SRanges>
bool FunctionalArray<T,Function,SRanges...>::isConst() const
{
return true;
}
template <typename T, class Function, class... SRanges>
bool FunctionalArray<T,Function,SRanges...>::isSlice() const
{
return false;
}
template <typename T, class Function, class... SRanges>
std::shared_ptr<ArrayBase<T,AnonymousRange> > FunctionalArray<T,Function,SRanges...>::anonymous(bool slice) const
{
assert(0); // think about it carefully
return nullptr;
}
template <typename T, class Function, class... SRanges>
ConstOperationRoot<T,SRanges...> FunctionalArray<T,Function,SRanges...>::
operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const
{
if(not mMaPtr){
mMaPtr = std::make_shared<MAType>( MAB::mRange->space() );
(*mMaPtr)(inds...) = exec(inds...);
}
return ConstOperationRoot<T,SRanges...>( *mMaPtr, inds... );
}
template <typename T, class Function, class... SRanges>
auto FunctionalArray<T,Function,SRanges...>::
exec(const std::shared_ptr<typename SRanges::IndexType>&... inds) const
-> Operation<T,Function,MetaOperationRoot<SRanges>...>
{
return mkOperation( mFunc, MetaOperationRoot<SRanges>( inds ) ... );
}
} // namespace CNORXZ

View file

@ -1,61 +0,0 @@
#ifndef __cxz_functional_array__
#define __cxz_functional_array__
#include "cxz_array_base.h"
#include "slice.h"
namespace CNORXZ
{
template <typename T, class Function, class... SRanges>
class FunctionalArray : public ArrayBase<T,SRanges...>
{
public:
typedef ContainerRange<SRanges...> CRange;
typedef ArrayBase<T,SRanges...> MAB;
typedef ConstContainerIndex<T,typename SRanges::IndexType...> IndexType;
typedef Array<T,SRanges...> MAType;
typedef T value_type;
private:
mutable T mVal;
std::shared_ptr<Function> mFunc;
mutable std::shared_ptr<MAType> mMaPtr;
public:
DEFAULT_MEMBERS(FunctionalArray);
FunctionalArray(const std::shared_ptr<SRanges>&... ranges, const std::shared_ptr<Function>& func);
FunctionalArray(const std::shared_ptr<SRanges>&... ranges);
FunctionalArray(const typename CRange::Space& space);
FunctionalArray(const typename CRange::Space& space, const std::shared_ptr<Function>& func);
virtual const T& operator[](const IndexType& i) const override;
virtual const T& at(const typename CRange::IndexType::MetaType& meta) const override;
virtual const T* data() const override;
virtual bool isConst() const override;
virtual bool isSlice() const override;
virtual std::shared_ptr<ArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
auto exec(const std::shared_ptr<typename SRanges::IndexType>&... inds) const
-> Operation<T,Function,MetaOperationRoot<SRanges>...>;
virtual ConstOperationRoot<T,SRanges...>
operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const override;
};
} // namespace CNORXZ
/* ========================= *
* --- TEMPLATE CODE --- *
* ========================= */
#endif

View file

@ -1,3 +1,14 @@
// -*- C++ -*-
/**
@file include/array/marray.cc.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_marray_cc_h__ #ifndef __cxz_marray_cc_h__
#define __cxz_marray_cc_h__ #define __cxz_marray_cc_h__

View file

@ -1,3 +1,14 @@
// -*- C++ -*-
/**
@file include/array/marray.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_marray_h__ #ifndef __cxz_marray_h__
#define __cxz_marray_h__ #define __cxz_marray_h__

View file

@ -1,3 +1,14 @@
// -*- C++ -*-
/**
@file include/array/slice.cc.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_slice_cc_h__ #ifndef __cxz_slice_cc_h__
#define __cxz_slice_cc_h__ #define __cxz_slice_cc_h__

View file

@ -1,3 +1,14 @@
// -*- C++ -*-
/**
@file include/array/slice.h
@brief ...
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_slice_h__ #ifndef __cxz_slice_h__
#define __cxz_slice_h__ #define __cxz_slice_h__