Skip to content
Snippets Groups Projects
Commit 0378a976 authored by Christian Engwer's avatar Christian Engwer
Browse files

remove expression template support, until it is properly implemented

[[Imported from SVN: r6596]]
parent b17f00a0
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,6 @@ AC_CONFIG_FILES([Makefile
dune/Makefile
dune/common/Makefile
dune/common/test/Makefile
dune/common/exprtmpl/Makefile
dune/common/parallel/Makefile
dune/common/parallel/test/Makefile
doc/Makefile
......
# $Id$
SUBDIRS = . test exprtmpl parallel
SUBDIRS = . test parallel
# the standard debug streams are put into the libdune
noinst_LTLIBRARIES = libcommon.la
......@@ -83,11 +83,4 @@ commoninclude_HEADERS = \
unused.hh \
version.hh
if EXPRESSIONTEMPLATES
commoninclude_HEADERS += exprtmpl.hh exprtmpl/scalar.inc exprtmpl/exprexpr.inc
libcommon_la_SOURCES += exprtmpl.cc
else
sourcescheck_NOSOURCES = exprtmpl.hh exprtmpl.cc
endif
include $(top_srcdir)/am/global-rules
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include "exprtmpl.hh"
/** This is only needed for debugging and will be removed in the future */
Indent INDENT;
This diff is collapsed.
# $Id: $
SOURCES = exprexpr.inc norm.inc scalar.inc
exprtmpldir = $(includedir)/dune/common/exprtmpl
exprtmpl_HEADERS = $(SOURCES)
include $(top_srcdir)/am/global-rules
// -*- C++ -*-
#ifndef OP
#error OP undefined
#endif
namespace ExprTmpl {
template <class A, class B>
class ExpressionOpExpression
{
public:
//#warning compare field_type of class A and B and choose infomation richest one!
typedef typename FieldType<A>::type field_type;
typedef typename BlockType<A>::type block_type;
typedef typename BlockExpression<ExpressionOpExpression>::type BlockExpr;
ExpressionOpExpression (const Expression<A> & _a, const Expression<B> & _b)
: a(_a), b(_b) {
#ifdef DUNE_ISTL_WITH_CHECKING
assert(a.N() == b.N());
#endif
}
BlockExpr operator[] (int i) const {
return a[i] OP b[i];
}
int N() const { return a.N(); };
private:
Expression<A> a;
Expression<B> b;
};
// Expression op Expression
template <class A, class B>
Expression< ExpressionOpExpression<A,B> >
operator OP (const Expression<A> & a, const Expression<B> & b)
{
ExpressionOpExpression<A,B> ex(a, b);
return Expression< ExpressionOpExpression<A,B> >(ex);
}
// Expression op Vector
template <class A, class B>
Expression< ExpressionOpExpression<A, ConstRef<B> > >
operator OP (const Expression<A> & a, const Vector<B> & b)
{
ConstRef<B> rb(b);
ExpressionOpExpression<A, ConstRef<B> > ex(a, rb);
return Expression< ExpressionOpExpression<A, ConstRef<B> > >(ex);
}
// Expression op FieldVector<K,1>
template <class A, class K>
K operator OP (const Expression<A> & a,
const Expression< ConstRef< FieldVector<K,1> > >& b)
{
return a OP b[0];
}
// Vector op Expression
template <class A, class B>
Expression< ExpressionOpExpression< ConstRef<A>, B> >
operator OP (const Vector<A> & a, const Expression<B> & b)
{
ConstRef<A> ra(a);
ExpressionOpExpression< ConstRef<A>, B> ex(ra, b);
return Expression< ExpressionOpExpression<ConstRef<A>, B> >(ex);
}
// FieldVector<K,1> op Expression
template <class K, class B>
K operator OP (const Expression< ConstRef< FieldVector<K,1> > > & a,
const Expression<B> & b)
{
return a[0] OP b;
}
// Vector op Vector
template <class V>
Expression< ExpressionOpExpression< ConstRef<V>, ConstRef<V> > >
operator OP (const Vector<V> & a, const Vector<V> & b)
{
ConstRef<V> ra(a);
ConstRef<V> rb(b);
ExpressionOpExpression< ConstRef<V>, ConstRef<V> > ex(ra, rb);
return Expression< ExpressionOpExpression< ConstRef<V>, ConstRef<V> > >(ex);
}
// FieldVector<K,1> op FieldVector<K,1>
template <class K>
K operator OP (const Expression< ConstRef< FieldVector<K,1> > > & a,
const Expression< ConstRef< FieldVector<K,1> > > & b)
{
return a[0] OP b[0];
}
// TypeTraits
template<class A, class B>
struct BlockExpression< ExpressionOpExpression<A,B> >
{
typedef
typename SelectType<
// decide whether we are at the and of the recusrion
isEndOfExpressionRecusion<typename BlockType<A>::type>::value,
// select FieldType if where are at the end of the recursion
typename FieldType<A>::type,
// construct nested expression otherwise
ExprTmpl::Expression<
ExprTmpl::ExpressionOpExpression<
typename ExpressionImp< typename BlockExpression<
typename ExpressionImp<A>::type>::type>::type,
typename ExpressionImp< typename BlockExpression<
typename ExpressionImp<B>::type>::type>::type > >
>::Type type;
};
template <class A, class B>
struct ExpressionImp< ExpressionOpExpression<A,B> >
{
typedef ExpressionOpExpression<A,B> type;
};
}
template <class A, class B>
struct FieldType< ExprTmpl::ExpressionOpExpression<A,B> >
{
typedef typename FieldType<A>::type type;
};
template <class A, class B>
struct BlockType< ExprTmpl::ExpressionOpExpression<A,B> >
{
typedef typename BlockType<A>::type type;
};
#undef ExpressionOpExpression
#undef OP
// -*- C++ -*-
#ifndef NORM
#error NORM undefined
#endif
#ifndef NORM_CODE
#error NORM_CODE undefined
#endif
#ifndef VAL_CODE
#error VAL_CODE undefined
#endif
template <class A>
typename FieldType<A>::type
NORM (const ExprTmpl::Expression<A> & a)
{
NORM_CODE
}
template <class A>
typename FieldType<A>::type
NORM (const ExprTmpl::Vector<A> & a)
{
NORM_CODE
}
/*
template <class A>
double
ExprTmpl::Expression<A>::NORM () const
{
const ExprTmpl::Expression<A> & a = *this;
NORM_CODE
}
template <class A>
double
ExprTmpl::Vector<A>::NORM () const
{
const ExprTmpl::Vector<A> & a = *this;
NORM_CODE
}
template <class A>
double
ExprTmpl::ConstRef<A>::NORM () const
{
const ExprTmpl::ConstRef<A> & a = *this;
NORM_CODE
}
*/
inline double
NORM (const double & a)
{
VAL_CODE
}
inline float
NORM (const float & a)
{
VAL_CODE
}
inline int
NORM (const int & a)
{
VAL_CODE
}
#undef NORM
#undef NORM_CODE
#undef VAL_CODE
// -*- C++ -*-
#ifndef OP
#error OP undefined
#endif
#ifdef ExpressionOpScalar
namespace ExprTmpl {
template <class A>
class ExpressionOpScalar
{
public:
typedef typename FieldType<A>::type field_type;
typedef typename BlockType<A>::type block_type;
typedef typename BlockExpression<ExpressionOpScalar>::type BlockExpr;
ExpressionOpScalar (const Expression<A> & _a,
const typename FieldType<A>::type & _lambda)
: a(_a), lambda(_lambda) {}
BlockExpr operator[] (int i) const {
return a[i] OP lambda;
}
int N() const { return a.N(); };
private:
Expression<A> a;
const field_type lambda;
};
// Scalar op FieldVector<K,1>
template <class K>
K operator OP (const Expression< ConstRef< FieldVector<K,1> > > & a,
const K & lambda)
{
return a[0] OP lambda;
}
// Vector op Scalar
template <class A>
Expression< ExpressionOpScalar<ConstRef<A> > >
operator OP (const Vector<A> & a, const typename FieldType<A>::type & lambda)
{
ConstRef<A> ra(a);
ExpressionOpScalar< ConstRef<A> > ex(ra, lambda);
return Expression< ExpressionOpScalar<ConstRef<A> > >(ex);
}
// Expression op Scalar
template <class A>
Expression< ExpressionOpScalar<A> >
operator OP (const Expression<A> & a, const typename FieldType<A>::type & lambda)
{
ExpressionOpScalar<A> ex(a, lambda);
return Expression< ExpressionOpScalar<A> >(ex);
}
// TypeTraits
//#warning Kann hier nicht das innere ExpressionImp weg?
template <class Ex>
struct BlockExpression< ExprTmpl::ExpressionOpScalar<Ex> >
{
typedef
typename SelectType<
isEndOfExpressionRecusion< typename BlockType<Ex>::type >::value,
typename FieldType<Ex>::type,
ExprTmpl::Expression<
ExprTmpl::ExpressionOpScalar<typename ExpressionImp<
typename BlockExpression<
typename ExpressionImp<Ex>::type>::type>::type > >
>::Type type;
};
template <class Ex>
struct ExpressionImp< ExprTmpl::ExpressionOpScalar<Ex> >
{
typedef ExprTmpl::ExpressionOpScalar< Ex > type;
};
} // namespace ExprTmpl
template <class A>
struct FieldType< ExprTmpl::ExpressionOpScalar<A> >
{
typedef typename FieldType<A>::type type;
};
template <class A>
struct BlockType< ExprTmpl::ExpressionOpScalar<A> >
{
typedef typename BlockType<A>::type type;
};
#undef ExpressionOpScalar
#endif
#ifdef ScalarOpExpression
namespace ExprTmpl {
template <class A>
class ScalarOpExpression
{
public:
typedef typename FieldType<A>::type field_type;
typedef typename BlockType<A>::type block_type;
typedef typename BlockExpression<ScalarOpExpression>::type BlockExpr;
ScalarOpExpression (const Expression<A> & _a,
const typename FieldType<A>::type & _lambda)
: a(_a), lambda(_lambda) {}
BlockExpr operator[] (int i) const {
return lambda OP a[i];
}
int N() const { return a.N(); };
private:
Expression<A> a;
const field_type lambda;
};
// Scalar op FieldVector<K,1>
template <class K>
K operator OP (const K & lambda,
const Expression< ConstRef< FieldVector<K,1> > > & a)
{
return lambda OP a[0];
}
// Scalar op Vector
template <class A>
Expression< ScalarOpExpression<ConstRef<A> > >
operator OP (const typename FieldType<A>::type & lambda, const Vector<A> & a)
{
ConstRef<A> ra(a);
ScalarOpExpression< ConstRef<A> > ex(ra, lambda);
return Expression< ScalarOpExpression<ConstRef<A> > >(ex);
}
// Scalar op Expression
template <class A>
Expression< ScalarOpExpression<A> >
operator OP (const typename FieldType<A>::type & lambda, const Expression<A> & a)
{
ScalarOpExpression<A> ex(a, lambda);
return Expression< ScalarOpExpression<A> >(ex);
}
// TypeTraits
template <class Ex>
struct BlockExpression< ExprTmpl::ScalarOpExpression<Ex> >
{
typedef
typename SelectType<
isEndOfExpressionRecusion< typename BlockType<Ex>::type >::value,
typename FieldType<Ex>::type,
ExprTmpl::Expression<
ExprTmpl::ScalarOpExpression<typename ExpressionImp<
typename BlockExpression<
typename ExpressionImp<Ex>::type>::type>::type > >
>::Type type;
};
template <class Ex>
struct ExpressionImp< ExprTmpl::ScalarOpExpression<Ex> >
{
typedef ExprTmpl::ScalarOpExpression< Ex > type;
};
} // namespace ExprTmpl
template <class A>
struct FieldType< ExprTmpl::ScalarOpExpression<A> >
{
typedef typename FieldType<A>::type type;
};
template <class A>
struct BlockType< ExprTmpl::ScalarOpExpression<A> >
{
typedef typename BlockType<A>::type type;
};
#undef ScalarOpExpression
#endif
#undef OP
......@@ -28,7 +28,6 @@ ALLM4S = \
dune_deprecated.m4 \
dune_deprecated_cppflags.m4 \
dune_docu.m4 \
dune_exprtmpl.m4 \
dune_fieldvector_size_is_method.m4 \
dune_linkcxx.m4 \
dune_mpi.m4 \
......
......@@ -29,7 +29,6 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
AC_REQUIRE([DUNE_SET_MINIMAL_DEBUG_LEVEL])
AC_REQUIRE([DUNE_PATH_XDR])
AC_REQUIRE([DUNE_MPI])
AC_REQUIRE([DUNE_EXPRTMPL])
AC_REQUIRE([DUNE_TR1_HEADERS])
dnl Create the flag --enable-fieldvector-size-is-method
......
AC_DEFUN([DUNE_EXPRTMPL],[
# enable experimental features
AC_ARG_ENABLE(expressiontemplates,
AS_HELP_STRING([--enable-expressiontemplates],[enable experimental expression templates in dune]))
AS_IF([test "x$enable_expressiontemplates" = "xyes"],[
AC_DEFINE([DUNE_EXPRESSIONTEMPLATES], [1],
[Define to 1 if the experimental expression templates should be used])])
AM_CONDITIONAL([EXPRESSIONTEMPLATES],
[test "x$enable_expressiontemplates" = "xyes"])
])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment