Starting Eigen 2 development. The current plan is to use the last

release of tvmet (inactive for 2 years and developer unreachable) as the
basis for eigen2, because it provides seemingly good expression template
mechanisms, we want that, and it would take years to reinvent that
wheel. We'll see. So this commit imports the last tvmet release.
This commit is contained in:
Benoit Jacob
2007-05-30 06:24:51 +00:00
commit 3036eeca0a
244 changed files with 95342 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
EXTRA_DIST = README t.cc
EXTRA_PROGRAMS = \
swap \
bad_temps \
bad_xpr_const_ref \
tvmet
AM_CXXFLAGS= -I$(top_srcdir)/include -I$(top_builddir)/include
swap_SOURCES = swap.cc
bad_temps_SOURCES = bad_temps.cc
bad_xpr_const_ref_SOURCES = bad_xpr_const_ref.cc
tvmet_SOURCES = tvmet.cc
tests: $(EXTRA_PROGRAMS)

View File

@@ -0,0 +1,470 @@
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SOURCES = $(bad_temps_SOURCES) $(bad_xpr_const_ref_SOURCES) $(swap_SOURCES) $(tvmet_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
EXTRA_PROGRAMS = swap$(EXEEXT) bad_temps$(EXEEXT) \
bad_xpr_const_ref$(EXEEXT) tvmet$(EXEEXT)
subdir = tests
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/config/ac_c_long_long.m4 \
$(top_srcdir)/config/ac_create_prefix_config_h.m4 \
$(top_srcdir)/config/ac_cxx_have_complex.m4 \
$(top_srcdir)/config/ac_cxx_have_complex_math1.m4 \
$(top_srcdir)/config/ac_cxx_have_complex_math2.m4 \
$(top_srcdir)/config/ac_cxx_have_ieee_math.m4 \
$(top_srcdir)/config/ac_cxx_have_mutable.m4 \
$(top_srcdir)/config/ac_cxx_have_namespaces.m4 \
$(top_srcdir)/config/ac_cxx_have_sysv_math.m4 \
$(top_srcdir)/config/ac_cxx_partial_specialization.m4 \
$(top_srcdir)/config/ac_cxx_typename.m4 \
$(top_srcdir)/config/ac_set_compiler.m4 \
$(top_srcdir)/config/op_doxygen_doc.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = $(top_builddir)/config/config.h
CONFIG_CLEAN_FILES =
am_bad_temps_OBJECTS = bad_temps.$(OBJEXT)
bad_temps_OBJECTS = $(am_bad_temps_OBJECTS)
bad_temps_LDADD = $(LDADD)
am_bad_xpr_const_ref_OBJECTS = bad_xpr_const_ref.$(OBJEXT)
bad_xpr_const_ref_OBJECTS = $(am_bad_xpr_const_ref_OBJECTS)
bad_xpr_const_ref_LDADD = $(LDADD)
am_swap_OBJECTS = swap.$(OBJEXT)
swap_OBJECTS = $(am_swap_OBJECTS)
swap_LDADD = $(LDADD)
am_tvmet_OBJECTS = tvmet.$(OBJEXT)
tvmet_OBJECTS = $(am_tvmet_OBJECTS)
tvmet_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/config
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/bad_temps.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/bad_xpr_const_ref.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/swap.Po ./$(DEPDIR)/tvmet.Po
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(bad_temps_SOURCES) $(bad_xpr_const_ref_SOURCES) \
$(swap_SOURCES) $(tvmet_SOURCES)
DIST_SOURCES = $(bad_temps_SOURCES) $(bad_xpr_const_ref_SOURCES) \
$(swap_SOURCES) $(tvmet_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CONFIG_CPPUNIT_FALSE = @CONFIG_CPPUNIT_FALSE@
CONFIG_CPPUNIT_TRUE = @CONFIG_CPPUNIT_TRUE@
CONFIG_DOC_FALSE = @CONFIG_DOC_FALSE@
CONFIG_DOC_TRUE = @CONFIG_DOC_TRUE@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@
CPPUNIT_CONFIG = @CPPUNIT_CONFIG@
CPPUNIT_LIBS = @CPPUNIT_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CXX_DEBUG_FLAGS = @CXX_DEBUG_FLAGS@
CXX_OPTIMIZE_FLAGS = @CXX_OPTIMIZE_FLAGS@
CXX_WARN_FLAGS = @CXX_WARN_FLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DOXYGEN = @DOXYGEN@
DOXYGEN_HAVE_DOT = @DOXYGEN_HAVE_DOT@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LATEX_BATCHMODE = @LATEX_BATCHMODE@
LATEX_MODE = @LATEX_MODE@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
EXTRA_DIST = README t.cc
AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
swap_SOURCES = swap.cc
bad_temps_SOURCES = bad_temps.cc
bad_xpr_const_ref_SOURCES = bad_xpr_const_ref.cc
tvmet_SOURCES = tvmet.cc
all: all-am
.SUFFIXES:
.SUFFIXES: .cc .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu tests/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
bad_temps$(EXEEXT): $(bad_temps_OBJECTS) $(bad_temps_DEPENDENCIES)
@rm -f bad_temps$(EXEEXT)
$(CXXLINK) $(bad_temps_LDFLAGS) $(bad_temps_OBJECTS) $(bad_temps_LDADD) $(LIBS)
bad_xpr_const_ref$(EXEEXT): $(bad_xpr_const_ref_OBJECTS) $(bad_xpr_const_ref_DEPENDENCIES)
@rm -f bad_xpr_const_ref$(EXEEXT)
$(CXXLINK) $(bad_xpr_const_ref_LDFLAGS) $(bad_xpr_const_ref_OBJECTS) $(bad_xpr_const_ref_LDADD) $(LIBS)
swap$(EXEEXT): $(swap_OBJECTS) $(swap_DEPENDENCIES)
@rm -f swap$(EXEEXT)
$(CXXLINK) $(swap_LDFLAGS) $(swap_OBJECTS) $(swap_LDADD) $(LIBS)
tvmet$(EXEEXT): $(tvmet_OBJECTS) $(tvmet_DEPENDENCIES)
@rm -f tvmet$(EXEEXT)
$(CXXLINK) $(tvmet_LDFLAGS) $(tvmet_OBJECTS) $(tvmet_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bad_temps.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bad_xpr_const_ref.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvmet.Po@am__quote@
.cc.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cc.obj:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cc.lo:
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool ctags distclean distclean-compile \
distclean-generic distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-exec install-exec-am \
install-info install-info-am install-man install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am
tests: $(EXTRA_PROGRAMS)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

2
tvmet-1.7.1/tests/README Normal file
View File

@@ -0,0 +1,2 @@
This directory contains files only for the developer to check new features.
Therefore not all is working/compiling here.

View File

@@ -0,0 +1,243 @@
/*
* This acts as an example on how to not introduce temporaries
* for evaluating expressions. The problem is related to the
* prod() function, where the temps are going out of scope.
*/
extern "C" int printf(const char*, ...);
#ifndef restrict
#define restrict __restrict__
#endif
template<unsigned Rows, unsigned Cols> class Matrix;
struct XprNull { explicit XprNull() { } };
static inline
double operator+(const double& lhs, XprNull) { return lhs; }
struct fcnl_Assign { static inline void applyOn(double& restrict lhs, double rhs) { lhs = rhs; } };
template<unsigned Rows, unsigned Cols,
unsigned RowStride, unsigned ColStride>
struct MetaMatrix
{
enum {
doRows = (RowStride < Rows - 1) ? 1 : 0,
doCols = (ColStride < Cols - 1) ? 1 : 0
};
template<class Mtrx, class E, class Fcnl>
static inline
void assign2(Mtrx& mat, const E& expr, const Fcnl& fn) {
fn.applyOn(mat(RowStride, ColStride), expr(RowStride, ColStride));
MetaMatrix<Rows * doCols, Cols * doCols, RowStride * doCols, (ColStride+1) * doCols>::assign2(mat, expr, fn);
}
template<class Mtrx, class E, class Fcnl>
static inline
void assign(Mtrx& mat, const E& expr, const Fcnl& fn) {
MetaMatrix<Rows, Cols, RowStride, 0>::assign2(mat, expr, fn);
MetaMatrix<Rows * doRows, Cols * doRows, (RowStride+1) * doRows, 0>::assign(mat, expr, fn);
}
};
template<>
struct MetaMatrix<0, 0, 0, 0>
{
template<class Mtrx, class E, class Fcnl>
static inline void assign2(Mtrx&, const E&, const Fcnl&) { }
template<class Mtrx, class E, class Fcnl>
static inline void assign(Mtrx&, const E&, const Fcnl&) { }
};
template<unsigned Rows1, unsigned Cols1,
unsigned Cols2,
unsigned RowStride1, unsigned ColStride1,
unsigned RowStride2, unsigned ColStride2,
unsigned K>
struct MetaGemm
{
enum { doIt = (K != Cols1 - 1) };
static inline
double prod(const double* restrict lhs, const double* restrict rhs, unsigned i, unsigned j) {
return lhs[i * RowStride1 + K * ColStride1] * rhs[K * RowStride2 + j * ColStride2]
+ MetaGemm<Rows1 * doIt, Cols1 * doIt,
Cols2 * doIt, RowStride1 * doIt, ColStride1 * doIt,
RowStride2 * doIt, ColStride2 * doIt, (K+1) * doIt>::prod(lhs, rhs, i, j);
}
};
template<>
struct MetaGemm<0,0,0,0,0,0,0,0>
{
static inline XprNull prod(const void*, const void*, unsigned, unsigned) { return XprNull(); }
};
template<unsigned Rows1, unsigned Cols1,
unsigned Cols2,
unsigned RowStride1, unsigned ColStride1,
unsigned RowStride2, unsigned ColStride2>
struct XprMMProduct
{
explicit XprMMProduct(const double* restrict lhs, const double* restrict rhs) : m_lhs(lhs), m_rhs(rhs) { }
double operator()(unsigned i, unsigned j) const {
return MetaGemm<Rows1, Cols1,
Cols2,
RowStride1, ColStride1,
RowStride2, ColStride2, 0>::prod(m_lhs, m_rhs, i, j);
}
private:
const double* restrict m_lhs;
const double* restrict m_rhs;
};
template<class E>
struct XprMatrixTranspose
{
explicit XprMatrixTranspose(const E& e) : m_expr(e) { }
double operator()(unsigned i, unsigned j) const { return m_expr(j, i); }
private:
const E& restrict m_expr;
};
template<class E, unsigned Rows, unsigned Cols>
struct XprMatrix
{
explicit XprMatrix(const E& e) : m_expr(e) { }
double operator()(unsigned i, unsigned j) const { return m_expr(i, j); }
private:
const E& restrict m_expr;
};
template<unsigned Rows, unsigned Cols,
unsigned RowStride, unsigned ColStride>
struct MatrixConstReference
{
explicit MatrixConstReference(const Matrix<Rows, Cols>& rhs) : m_data(rhs.m_data) { }
double operator()(unsigned i, unsigned j) const {
return m_data[i * RowStride + j * ColStride];
}
private:
const double* restrict m_data;
};
template<unsigned Rows, unsigned Cols>
struct Matrix
{
explicit Matrix() { m_data = new double [Rows*Cols]; }
template<class E>
explicit Matrix(const XprMatrix<E, Rows, Cols>& rhs) {
m_data = new double [Rows*Cols];
MetaMatrix<Rows, Cols, 0, 0>::assign(*this, rhs, fcnl_Assign());
}
~Matrix() { delete [] m_data; }
double& restrict operator()(unsigned i, unsigned j) { return m_data[i * Cols + j]; }
double operator()(unsigned i, unsigned j) const { return m_data[i * Cols + j]; }
MatrixConstReference<Rows,Cols,Cols,1> const_ref() const {
return MatrixConstReference<Rows,Cols,Cols,1>(*this);
}
template <class E> Matrix& operator=(const XprMatrix<E, Rows, Cols>& rhs) {
MetaMatrix<Rows, Cols, 0, 0>::assign(*this, rhs, fcnl_Assign());
return *this;
}
void print() const {
printf("[\n");
for(unsigned i = 0; i != Rows; ++i) {
printf("\t[");
for(unsigned j = 0; j != Cols; ++j)
printf("\t%+4.2f", this->operator()(i, j));
printf("]\n");
}
printf("]\n");
}
// private:
double* m_data;
};
template<class E1, unsigned Rows1, unsigned Cols1, unsigned Cols2>
inline
XprMatrix<
XprMMProduct<
Rows1, Cols1, Cols2,
Cols1, 1, Cols2, 1
>,
Rows1, Cols2
>
prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const Matrix<Cols1, Cols2>& rhs) {
typedef XprMMProduct<
Rows1, Cols1, Cols2,
Cols1, 1, Cols2, 1
> expr_type;
Matrix<Rows1, Cols1> temp_lhs(lhs);
return XprMatrix<expr_type, Rows1, Cols2>(expr_type(temp_lhs.m_data, rhs.m_data));
}
template<unsigned Rows, unsigned Cols>
inline
XprMatrix<
XprMatrixTranspose<
MatrixConstReference<Rows, Cols, Cols, 1>
>,
Cols, Rows
>
trans(const Matrix<Rows, Cols>& rhs) {
typedef XprMatrixTranspose<
MatrixConstReference<Rows, Cols, Cols, 1>
> expr_type;
return XprMatrix<expr_type, Cols, Rows>(expr_type(rhs.const_ref()));
}
/**
* Test driver
*/
using namespace std;
int main()
{
Matrix<3,2> B;
Matrix<3,3> D;
Matrix<2,2> K;
B(0,0) = -0.05; B(0,1) = 0;
B(1,0) = 0; B(1,1) = 0.05;
B(2,0) = 0.05; B(2,1) = -0.05;
D(0,0) = 2000; D(0,1) = 1000; D(0,2) = 0;
D(1,0) = 1000; D(1,1) = 2000; D(1,2) = 0;
D(2,0) = 0; D(2,1) = 0; D(2,2) = 500;
K = prod(prod(trans(B), D), B);
printf("K = ");
K.print(); // wrong result, should be symetric
}

View File

@@ -0,0 +1,164 @@
/*
* $Id: bad_xpr_const_ref.cc,v 1.1 2003/10/21 19:40:38 opetzold Exp $
*
* This example shows the problem on holding references
* by expressions. On higher optimization levels all things
* are good. Without optimizations it crashs.
*/
extern "C" int printf(const char*, ...);
#ifndef restrict
#define restrict __restrict__
#endif
template<unsigned Sz> class Vector;
struct Fcnl_Assign {
static inline void apply_on(double& restrict lhs, double rhs) { lhs = rhs; }
};
struct Fcnl_Add {
static inline double apply_on(double lhs, double rhs) { return lhs + rhs; }
};
template<unsigned Sz, unsigned Stride=0>
struct MetaVector
{
enum {
doIt = (Stride < (Sz-1)) ? 1 : 0
};
template <class E1, class E2, class Fcnl>
static inline
void assign(E1& lhs, const E2& rhs, const Fcnl& fn) {
fn.apply_on(lhs(Stride), rhs(Stride));
MetaVector<Sz * doIt, (Stride+1) * doIt>::assign(lhs, rhs, fn);
}
};
template<>
struct MetaVector<0,0>
{
template <class E1, class E2, class Fcnl>
static inline void assign(E1&, const E2&, const Fcnl&) { }
};
template<class E, unsigned Sz>
struct XprVector
{
explicit XprVector(const E& e) : m_expr(e) { }
double operator()(unsigned i) const {
return m_expr(i);
}
template<class E2, class Fcnl>
void assign_to(E2& e, const Fcnl& fn) const {
MetaVector<Sz, 0>::assign(e, *this, fn);
}
const E m_expr;
};
template<unsigned Sz, unsigned Stride=1>
struct VectorConstReference
{
explicit VectorConstReference(const Vector<Sz>& rhs) : m_data(rhs.m_data) { }
double operator()(unsigned i) const {
return m_data[i * Stride];
}
const double* restrict m_data;
};
template<unsigned Sz>
struct Vector
{
explicit Vector() { }
double& restrict operator()(unsigned i) { return m_data[i]; }
double operator()(unsigned i) const { return m_data[i]; }
typedef VectorConstReference<Sz, 1> ConstReference;
ConstReference const_ref() const { return ConstReference(*this); }
template<class Fcnl>
void assign_to(Vector& v, const Fcnl& fn) {
MetaVector<Sz, 0>::assign(v, *this, fn);
}
template<class E>
Vector& operator=(const XprVector<E, Sz>& rhs) {
rhs.assign_to(*this, Fcnl_Assign());
return *this;
}
double m_data[Sz];
};
template<class BinOp, class E1, class E2>
struct XprBinOp
{
explicit XprBinOp(const E1& lhs, const E2& rhs)
: m_lhs(lhs), m_rhs(rhs)
{ }
double operator()(unsigned i) const {
return BinOp::apply_on(m_lhs(i), m_rhs(i));
}
const E1& m_lhs;
const E2& m_rhs;
};
template<unsigned Sz>
inline
XprVector<
XprBinOp<
Fcnl_Add,
VectorConstReference<Sz>,
VectorConstReference<Sz>
>,
Sz
>
add (const Vector<Sz>& lhs, const Vector<Sz>& rhs) {
typedef XprBinOp <
Fcnl_Add,
VectorConstReference<Sz>,
VectorConstReference<Sz>
> expr_type;
return XprVector<expr_type, Sz>(
expr_type(lhs.const_ref(), rhs.const_ref()));
}
int main()
{
Vector<5> v, v1,v2;
v1(0) = 1;
v1(1) = 2;
v1(2) = 3;
v1(3) = 4;
v1(4) = 5;
v2(0) = 1;
v2(1) = 2;
v2(2) = 3;
v2(3) = 4;
v2(4) = 5;
v = add(v1, v2);
printf("v(0) = %f\n", v(0));
}

154
tvmet-1.7.1/tests/swap.cc Normal file
View File

@@ -0,0 +1,154 @@
/*
* Test file for checking meta swap feature.
*
* Swapping using std::swap is faster than meta template implementation.
*/
#include <iostream>
#include <algorithm> // min, max
#include <tvmet/Matrix.h>
#include <tvmet/Vector.h>
using namespace tvmet;
using namespace std;
NS_TVMET_BEGIN
template<size_t Sz, size_t Idx=0>
class MetaSwap // later, should be MetaVector
{
private:
enum {
doIt = (Idx < (Sz-1)) ? 1 : 0 /**< recursive counter */
};
public:
template<class E1, class E2>
static inline
void
swap(E1& e1, E2& e2) {
// XXX BUG: const problem?, we have to use the operator() for Vectors
fcnl_Swap<typename E1::value_type, typename E2::value_type>::applyOn(e1(Idx), e2(Idx));
MetaSwap<Sz * doIt, (Idx+1) * doIt>::swap(e1, e2);
}
};
template<>
class MetaSwap<0, 0>
{
public:
template<class E1, class E2> static inline void swap(E1&, E2&) { }
};
/**
* \fun swap
* \brief swaps to vector expressions XprVector<E, Sz>
*/
template<class E1, class E2, size_t Sz>
inline
void swap(XprVector<E1, Sz> e1, XprVector<E2, Sz> e2) {
MetaSwap<Sz>::swap(e1, e2);
}
/**
* \fun swap
* \brief swaps to vector
*/
template<class T1, class T2, size_t Sz>
inline
void swap(Vector<T1, Sz>& lhs, Vector<T2, Sz>& rhs) {
swap(lhs.asXpr(), rhs.asXpr());
}
/**
* \fun swap2
* \brief swaps to vector expressions XprVector<E, Sz>
*/
template<class E1, class E2, size_t Sz>
inline
void swap2(XprVector<E1, Sz> e1, XprVector<E2, Sz> e2) {
// loops are faster than meta templates
for(size_t i = 0; i < Sz; ++i)
std::swap(e1[i], e2[i]);
}
/**
* \fun swap2
* \brief swaps to vector
*/
template<class T1, class T2, size_t Sz>
inline
void swap2(Vector<T1, Sz>& lhs, Vector<T2, Sz>& rhs) {
// loops are faster than meta templates
for(size_t i = 0; i < Sz; ++i)
std::swap(lhs[i], rhs[i]);
}
NS_TVMET_END
template<class V1, class V2>
void test_meta_swap(V1& v1, V2& v2) {
tvmet::swap(v1, v2);
}
template<class V1, class V2>
void test_loop_swap(V1& v1, V2& v2) {
tvmet::swap2(v1, v2);
}
template<class M1, class M2>
void test_meta_mswap(M1& m1, M2& m2) {
tvmet::swap2(row(m1, 0), row(m2, 0));
tvmet::swap2(col(m1, 0), col(m2, 0));
}
#define LOOPS 1000000
int main() {
typedef Matrix<double, 4, 4> matrix_type;
typedef Vector<double, 4> vector_type;
//----------------------------------------------------------------
vector_type v1(1);
vector_type v2(4);
cout << "\nSwap Vectors\n\n";
cout << v1 << endl;
cout << v2 << endl;
for(size_t i = 0; i < LOOPS; ++i)
test_meta_swap(v1, v2);
cout << v1 << endl;
cout << v2 << endl;
for(size_t i = 0; i < LOOPS; ++i)
test_loop_swap(v1, v2);
cout << v1 << endl;
cout << v2 << endl;
//----------------------------------------------------------------
matrix_type m1, m2;
vector_type rv;
m1 = 1,2,3,4,
5,6,7,8,
9,10,11,12,
13,14,15,16;
m2 = transpose(m1);
cout << "\nSwap Matrix\n\n";
cout << m1 << endl;
cout << m2 << endl;
test_meta_mswap(m1, m2);
cout << m1 << endl;
cout << m2 << endl;
}

414
tvmet-1.7.1/tests/t.cc Normal file
View File

@@ -0,0 +1,414 @@
#include <iostream>
#include <tvmet/Vector.h>
#include <tvmet/Matrix.h>
using std::cout;
using std::endl;
struct separator {
std::ostream& print_on(std::ostream& os) const {
for(std::size_t i = 0; i < 63; ++i) os << "-";
return os;
}
};
std::ostream& operator<<(std::ostream& os, const separator& s) {
return s.print_on(os);
}
template<class T1, class T2 = T1>
class TestBase
{
public:
typedef T1 value_type;
typedef T2 value_type2;
typedef tvmet::Vector<value_type, 3> vector_type;
typedef tvmet::Matrix<value_type, 3, 3> matrix_type;
typedef tvmet::Vector<value_type2, 3> vector_type2;
typedef tvmet::Matrix<value_type2, 3, 3> matrix_type2;
private:
vector_type v0;
matrix_type M0;
protected:
vector_type v1, v2, v3;
matrix_type M1, M2, M3;
protected:
TestBase()
{
v0 = 1,2,3;
M0 = 1,4,7,2,5,8,3,6,9;
reset();
}
~TestBase() { }
void reset()
{
v1 = v0; v2 = v0; v3 = v0;
M1 = M0; M2 = M0; M3 = M0;
}
public:
void show_v1(const std::string& op) {
cout << separator() << endl
<< op << " = "
<< v1 << endl
<< separator() << endl;
}
void show_v2(const std::string& op) {
cout << separator() << endl
<< op << " = "
<< v2 << endl
<< separator() << endl;
}
void show_v3(const std::string& op) {
cout << separator() << endl
<< op << " = "
<< v3 << endl
<< separator() << endl;
}
void show_v() {
cout << separator() << endl;
cout << "v1 = " << v1 << endl
<< "v2 = " << v2 << endl
<< "v3 = " << v3 << endl;
cout << separator() << endl;
}
void show_M1(const std::string& op) {
cout << separator() << endl
<< op << " = "
<< M1 << endl
<< separator() << endl;
}
void show_M2(const std::string& op) {
cout << separator() << endl
<< op << " = "
<< M2 << endl
<< separator() << endl;
}
void show_M3(const std::string& op) {
cout << separator() << endl
<< op << " = "
<< M3 << endl
<< separator() << endl;
}
void show_M() {
cout << separator() << endl;
cout << "M1 = " << M1 << endl
<< "M2 = " << M2 << endl
<< "M3 = " << M3 << endl;
cout << separator() << endl;
}
};
/*
* Vector
*/
class TestV : public TestBase<double>
{
public:
TestV() { }
public:
void case1() {
reset();
v1 = v2 + v2 + v3;
show_v1("v2 + v2 + v3");
}
void case2() {
reset();
v1 = sin( (v2 + v2) * v2 );
show_v1("sin( (v2 + v2) * v2 )");
}
void case3() {
reset();
v1 = (v2 + v2) * (v2 + v2);
show_v1("(v2 + v2) * (v2 + v2)");
}
void case4() {
reset();
v1 = (v2 + v2) * (v2 + v2) / 4;
show_v1("(v2 + v2) * (v2 + v2) / 4");
}
void case5() {
reset();
}
};
/*
* Matrix
*/
class TestM : public TestBase<double>
{
public:
TestM() { }
public:
void case1() {
reset();
M1 = M2 + M3;
show_M1("M2 + M3");
}
void case2() {
reset();
M1 = M2 + M2 + M2 + M2;
show_M1("M2 + M2 + M2 + M2");
}
void case3() {
reset();
/*
XXX: missing feature element_wise XprMatrix * Xprmatrix
M1 = ( M2 + M2 ) * ( M2 + M2 );
M1 = tvmet::element_wise::product( M2 + M2, M2 + M2 );
show_M1("empty");
*/
}
void case4() {
reset();
M1 = sin(M2 + M2); // UFUNC(XprMatrix)
show_M1("sin(M2 + M2)");
}
void case5() {
reset();
M1 = trans(M2); // = XprMatrix
show_M1("trans(M2)");
}
void case6() {
reset();
M1 = trans(M2) + M2; // XprMatrix + Matrix
show_M1("trans(M2) + M2");
}
void case7() {
reset();
M1 = M2 + trans(M2); // Matrix + XprMatrix
show_M1("M2 + trans(M2)");
}
void case8() {
reset();
/*
* WRONG results, should be:
* 120 264 408
* 144 324 504
* 168 384 600
* there seems to be a side effect!!
*/
M1 = prod((M2 + M2), (M2 + M2)); // XprMatrix * XprMatrix
show_M1("prod((M2 + M2), (M2 + M2))");
}
void case9() {
reset();
M1 = (M2 + M2) * (M2 + M2); // XprMatrix * XprMatrix
show_M1("(M2 + M2) * (M2 + M2)");
}
void case10() {
reset();
}
};
/*
* Matrix-Vector
*/
class TestMV : public TestBase<double>
{
public:
TestMV() { }
public:
void case1() {
reset();
v1 = M1 * v2;
show_v1("M1 * v2");
}
void case2() {
reset();
v1 = (M1 * v2) + v2;
show_v1("(M1 * v2) + v2");
}
void case3() {
reset();
v1 = (M1 * v2) + (M1 * v2);
show_v1("(M1 * v2) + (M1 * v2)");
}
void case4() {
reset();
v1 = (M1 * v2) * (M1 * v2); // element wise: XprVector * XprVector
show_v1("element_wise: (M1 * v2) * (M1 * v2)");
}
void case5() {
reset();
using namespace tvmet::element_wise;
v1 = (M1 * v2) / (M1 * v2); // element_wise: XprVector / XprVector
show_v1("element_wise: (M1 * v2) / (M1 * v2)");
}
void case6() {
reset();
v1 = prod(M1, v2);
show_v1("trans_prod(M1, v2)");
}
void case7() {
reset();
v1 = prod(M1, v2) + v2;// XprVector + Vector
show_v1("prod(M1, v2) + v2");
}
void case8() {
reset();
using namespace tvmet::element_wise;
v1 += prod(M1, v2) / v2;// element_wise: XprVector + Vector
show_v1("v1 += prod(M1, v2) / v2");
}
void case9() {
reset();
v1 = prod(M1, v2) + prod(M1, v2);// element wise: XprVector * XprVector
show_v1("prod(M1, v2) + prod(M1, v2)");
}
void case10() {
reset();
using namespace tvmet::element_wise;
v1 = prod(M1, v2) / prod(M1, v2);// element_wise: XprVector / XprVector
all_elements( v1 == 1 );
show_v1("prod(M1, v2) / prod(M1, v2)");
}
void case11() {
reset();
v1 = M1 * (v1+v1);
show_v1("M1 * (v1+v1)");
}
void case12() {
reset();
v1 = M1 * prod(M1, v2);
show_v1("M1 * prod(M1, v2)");
}
};
/*
* Main
*/
int main()
{
tvmet::Matrix<double, 3,3> MM;
MM = 1,2,3,4,5,6,7,8,9;
tvmet::Matrix<double, 3,3> MM2( MM );
TestV v;
TestM M;
TestMV Mv;
v.show_v();
M.show_M();
cout << "*****************************************************************" << endl;
#if 1
v.case1();
v.case2();
v.case3();
v.case4();
v.case5();
cout << "*****************************************************************" << endl;
#endif
#if 1
M.case1();
M.case2();
M.case3();
M.case4();
M.case5();
M.case6();
M.case7();
M.case8();
M.case9();
M.case10();
cout << "*****************************************************************" << endl;
#endif
#if 1
Mv.case1();
Mv.case2();
Mv.case3();
Mv.case4();
Mv.case5();
#endif
Mv.case6();
Mv.case7();
Mv.case8();
Mv.case9();
Mv.case10();
Mv.case11();
Mv.case12();
}

312
tvmet-1.7.1/tests/tvmet.cc Normal file
View File

@@ -0,0 +1,312 @@
/*
* $Id: tvmet.cc,v 1.3 2003/10/21 19:37:06 opetzold Exp $
*
* This file shows the basic principle used by tvmet. Therefore
* you will not find promotion etc. here.
*/
extern "C" int printf(const char*, ...);
#ifndef restrict
#define restrict __restrict__
#endif
template<unsigned Rows, unsigned Cols> class Matrix;
struct XprNull { explicit XprNull() { } };
static inline
double operator+(const double& lhs, XprNull) { return lhs; }
struct Fcnl_Assign { static inline void apply_on(double& restrict lhs, double rhs) { lhs = rhs; } };
template<unsigned Rows, unsigned Cols,
unsigned RowStride, unsigned ColStride>
struct MetaMatrix
{
enum {
doRows = (RowStride < Rows - 1) ? 1 : 0,
doCols = (ColStride < Cols - 1) ? 1 : 0
};
template<class E1, class E2, class Fcnl>
static inline
void assign2(E1& lhs, const E2& rhs, const Fcnl& fn) {
fn.apply_on( lhs(RowStride, ColStride), rhs(RowStride, ColStride) );
MetaMatrix<Rows * doCols, Cols * doCols, RowStride * doCols, (ColStride+1) * doCols>::assign2(lhs, rhs, fn);
}
template<class E1, class E2, class Fcnl>
static inline
void assign(E1& lhs, const E2& rhs, const Fcnl& fn) {
MetaMatrix<Rows, Cols, RowStride, 0>::assign2(lhs, rhs, fn);
MetaMatrix<Rows * doRows, Cols * doRows, (RowStride+1) * doRows, 0>::assign(lhs, rhs, fn);
}
};
template<>
struct MetaMatrix<0, 0, 0, 0>
{
template<class E1, class E2, class Fcnl>
static inline void assign2(E1&, const E2&, const Fcnl&) { }
template<class E1, class E2, class Fcnl>
static inline void assign(E1&, const E2&, const Fcnl&) { }
};
template<unsigned Rows1, unsigned Cols1,
unsigned Cols2,
unsigned RowStride1, unsigned ColStride1,
unsigned RowStride2, unsigned ColStride2,
unsigned K>
struct MetaGemm
{
enum { doIt = (K != Cols1 - 1) };
template<class E1, class E2>
static inline
double prod(const E1& lhs, const E2& rhs, unsigned i, unsigned j) {
return lhs(i, K) * rhs(K, j)
+ MetaGemm<Rows1 * doIt, Cols1 * doIt,
Cols2 * doIt, RowStride1 * doIt, ColStride1 * doIt,
RowStride2 * doIt, ColStride2 * doIt, (K+1) * doIt>::prod(lhs, rhs, i, j);
}
};
template<>
struct MetaGemm<0,0,0,0,0,0,0,0>
{
template<class E1, class E2>
static inline XprNull prod(const E1&, const E2&, unsigned, unsigned) { return XprNull(); }
};
template<class E1, class E2,
unsigned Rows1, unsigned Cols1,
unsigned Cols2,
unsigned RowStride1, unsigned ColStride1,
unsigned RowStride2, unsigned ColStride2>
struct XprMMProduct
{
explicit XprMMProduct(const E1& lhs, const E2& rhs) : m_lhs(lhs), m_rhs(rhs) { }
double operator()(unsigned i, unsigned j) const {
return MetaGemm<
Rows1, Cols1,
Cols2,
RowStride1, ColStride1,
RowStride2, ColStride2, 0>::prod(m_lhs, m_rhs, i, j);
}
// void assign_to(Matrix<Rows1, Cols2>& rhs) const {
// MetaMatrix<Rows1, Cols2, 0, 0>::assign(rhs, *this, Fcnl_Assign());
// }
private:
const E1 m_lhs;
const E2 m_rhs;
};
template<class E>
struct XprMatrixTranspose
{
explicit XprMatrixTranspose(const E& e) : m_expr(e) { }
double operator()(unsigned i, unsigned j) const { return m_expr(j, i); }
// template<unsigned Rows, unsigned Cols>
// void assign_to(Matrix<Rows, Cols>& rhs) const {
// MetaMatrix<Rows, Cols, 0, 0>::assign(rhs, *this, Fcnl_Assign());
// }
private:
const E m_expr;
};
template<class E, unsigned Rows, unsigned Cols>
struct XprMatrix
{
explicit XprMatrix(const E& e) : m_expr(e) { }
double operator()(unsigned i, unsigned j) const { return m_expr(i, j); }
void assign_to(Matrix<Rows, Cols>& rhs) const {
MetaMatrix<Rows, Cols, 0, 0>::assign(rhs, *this, Fcnl_Assign());
}
private:
const E m_expr;
};
template<unsigned Rows, unsigned Cols,
unsigned RowStride, unsigned ColStride>
struct MatrixConstReference
{
explicit MatrixConstReference(const Matrix<Rows, Cols>& rhs) : m_data(rhs.m_data) { }
double operator()(unsigned i, unsigned j) const {
return m_data[i * RowStride + j * ColStride];
}
private:
const double* restrict m_data;
};
template<unsigned Rows, unsigned Cols>
struct Matrix
{
explicit Matrix() { m_data = new double [Rows*Cols]; }
template<class E>
explicit Matrix(const XprMatrix<E, Rows, Cols>& rhs) {
m_data = new double [Rows*Cols];
MetaMatrix<Rows, Cols, 0, 0>::assign(*this, rhs, Fcnl_Assign());
}
~Matrix() { delete [] m_data; }
double& restrict operator()(unsigned i, unsigned j) { return m_data[i * Cols + j]; }
double operator()(unsigned i, unsigned j) const { return m_data[i * Cols + j]; }
MatrixConstReference<Rows,Cols,Cols,1> const_ref() const {
return MatrixConstReference<Rows,Cols,Cols,1>(*this);
}
Matrix& operator=(const Matrix<Rows, Cols>& rhs) {
rhs.assign_to(*this);
return *this;
}
void assign_to(Matrix<Rows, Cols>& rhs) const {
MetaMatrix<Rows, Cols, 0, 0>::assign(rhs, *this, Fcnl_Assign());
}
template <class E>
Matrix& operator=(const XprMatrix<E, Rows, Cols>& rhs) {
rhs.assign_to(*this);
return *this;
}
template <class E>
void assign_to(XprMatrix<E, Rows, Cols>& rhs) const {
MetaMatrix<Rows, Cols, 0, 0>::assign(rhs, *this, Fcnl_Assign());
}
void print() const {
printf("[\n");
for(unsigned i = 0; i != Rows; ++i) {
printf("\t[");
for(unsigned j = 0; j != Cols; ++j)
printf("\t%+4.2f", this->operator()(i, j));
printf("]\n");
}
printf("]\n");
}
double* m_data;
};
template<unsigned Rows1, unsigned Cols1,
unsigned Cols2>
inline
XprMatrix<
XprMMProduct<
MatrixConstReference<Rows1, Cols1, Cols1, 1>,
MatrixConstReference<Cols1, Cols2, Cols2, 1>,
Rows1, Cols1, // M1(Rows1, Cols1)
Cols2, // M2(Cols1, Cols2)
Cols1, 1, // Stride M1
Cols2, 1 // Stride M2
>,
Rows1, Cols2 // return Dim
>
prod(const Matrix<Rows1, Cols1>& lhs, const Matrix<Cols1, Cols2>& rhs) {
typedef XprMMProduct<
MatrixConstReference<Rows1, Cols1, Cols1, 1>,
MatrixConstReference<Cols1, Cols2, Cols2, 1>,
Rows1, Cols1,
Cols2,
Cols1, 1,
Cols2, 1
> expr_type;
return XprMatrix<expr_type, Rows1, Cols2>(
expr_type(lhs.const_ref(), rhs.const_ref()));
}
template<class E1, unsigned Rows1, unsigned Cols1, unsigned Cols2>
inline
XprMatrix<
XprMMProduct<
XprMatrix<E1, Rows1, Cols1>,
MatrixConstReference<Cols1, Cols2, Cols2, 1>,
Rows1, Cols1, Cols2,
Cols1, 1, Cols2, 1
>,
Rows1, Cols2
>
prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const Matrix<Cols1, Cols2>& rhs) {
typedef XprMMProduct<
XprMatrix<E1, Rows1, Cols1>,
MatrixConstReference<Cols1, Cols2, Cols2, 1>,
Rows1, Cols1, Cols2,
Cols1, 1, Cols2, 1
> expr_type;
return XprMatrix<expr_type, Rows1, Cols2>(expr_type(lhs, rhs.const_ref()));
}
template<unsigned Rows, unsigned Cols>
inline
XprMatrix<
XprMatrixTranspose<
MatrixConstReference<Rows, Cols, Cols, 1>
>,
Cols, Rows
>
trans(const Matrix<Rows, Cols>& rhs) {
typedef XprMatrixTranspose<
MatrixConstReference<Rows, Cols, Cols, 1>
> expr_type;
return XprMatrix<expr_type, Cols, Rows>(expr_type(rhs.const_ref()));
}
/**
* Test driver
*/
int main()
{
Matrix<3,2> B;
Matrix<3,3> D;
B(0,0) = -0.05; B(0,1) = 0;
B(1,0) = 0; B(1,1) = 0.05;
B(2,0) = 0.05; B(2,1) = -0.05;
D(0,0) = 2000; D(0,1) = 1000; D(0,2) = 0;
D(1,0) = 1000; D(1,1) = 2000; D(1,2) = 0;
D(2,0) = 0; D(2,1) = 0; D(2,2) = 500;
printf("B = ");
B.print();
printf("D = ");
D.print();
printf("\n***********************************************\n");
Matrix<2,2> K;
K = prod(prod(trans(B), D), B);
printf("Check: (equal prod(prod(trans(B), D), B)\n");
printf(" K = ");
K.print();
}