toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN/internal objects.h


From: Edward Rosten
Subject: [Toon-members] TooN/internal objects.h
Date: Thu, 11 Jun 2009 20:00:59 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Edward Rosten <edrosten>        09/06/11 20:00:59

Modified files:
        internal       : objects.h 

Log message:
        Allow scalable operators to change their overall type during scaling.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/objects.h?cvsroot=toon&r1=1.13&r2=1.14

Patches:
Index: objects.h
===================================================================
RCS file: /cvsroot/toon/TooN/internal/objects.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- objects.h   9 Jun 2009 13:33:23 -0000       1.13
+++ objects.h   11 Jun 2009 20:00:58 -0000      1.14
@@ -223,13 +223,17 @@
                return 
Operator<Internal::AddIdentity<Rows,Cols,P1,B1,Precision> >(val, m, 1);
        }
 
+       ///@}
+       template<class Q> struct ScaleType
+       {
+               typedef Operator<Internal::Identity<Q> > Type;
+       };
+
        template<class Pout, class Pmult> Operator<Internal::Identity<Pout> > 
scale_me(const Pmult& m) const
        {
                return Operator<Internal::Identity<Pout> >(val*m);
        }
 
-       ///@}
-
        Operator<Internal::SizedIdentity<Precision> > operator()(int s){
                return Operator<Internal::SizedIdentity<Precision> >(s);
        }
@@ -254,6 +258,11 @@
        int num_cols() const {return my_size;}
        ///@}
 
+       template<class Q> struct ScaleType
+       {
+               typedef Operator<Internal::SizedIdentity<Q> > Type;
+       };
+
        template<class Pout, class Pmult> 
Operator<Internal::SizedIdentity<Pout> > scale_me(const Pmult& m) const
        {
                return Operator<Internal::SizedIdentity<Pout> >(my_size, val*m);
@@ -446,6 +455,11 @@
                return Operator<Internal::RCScalars<Precision> > (s,r,c);
        }
 
+       template<class Q> struct ScaleType
+       {
+               typedef Operator<Internal::Scalars<Q> > Type;
+       };
+
        template<class Pout, class Pmult> Operator<Internal::Scalars<Pout> > 
scale_me(const Pmult& m) const
        {
                return Operator<Internal::Scalars<Pout> >(s*m);
@@ -474,6 +488,10 @@
        }
        ///@}
 
+       template<class Q> struct ScaleType
+       {
+               typedef Operator<Internal::SizedScalars<Q> > Type;
+       };
 private:
        void operator()(int);
        void operator()(int,int);
@@ -501,6 +519,11 @@
                :Operator<Internal::Scalars<P> >(s),my_rows(r),my_cols(c)
        {}
                
+       template<class Q> struct ScaleType
+       {
+               typedef Operator<Internal::RCScalars<Q> > Type;
+       };
+
        template<class Pout, class Pmult> Operator<Internal::RCScalars<Pout> > 
scale_me(const Pmult& m) const
        {
                return Operator<Internal::RCScalars<Pout> >(s*m, my_rows, 
my_cols);
@@ -518,25 +541,32 @@
 // How to scale scalable operators
 //
        
+template<class OpIn, class Pl, class Pr, class Binary>
+struct ScaleMapper
+{
+       typedef typename Binary::template Return<Pl,Pr>::Type Res;
+       typedef typename Operator<OpIn>::template ScaleType<Res>::Type Op;
+};
+       
 template<template<class> class Op, class Pl, class Pr> 
-Operator<Op<typename Internal::MultiplyType<Pl, Pr>::type > >
+typename ScaleMapper<Op<Pr>, Pl, Pr, Internal::Multiply>::Op
 operator*(const Pl& l, const Operator<Op<Pr> >& r)
 {
        return r.template scale_me<typename Internal::MultiplyType<Pl, 
Pr>::type, Pl>(l); 
 }
 
 template<template<class> class Op, class Pl, class Pr> 
-Operator<Op<typename Internal::MultiplyType<Pl, Pr>::type > >
+typename ScaleMapper<Op<Pl>, Pl, Pr, Internal::Multiply>::Op
 operator*(const Operator<Op<Pl> >& l, const Pr&  r)
 {
        return l.template scale_me<typename Internal::MultiplyType<Pl, 
Pr>::type, Pl>(r); 
 }
 
 template<template<class> class Op, class Pl, class Pr> 
-Operator<Op<typename Internal::DivideType<Pl, Pr>::type > >
+typename ScaleMapper<Op<Pl>, Pl, Pr, Internal::Divide>::Op
 operator/(const Operator<Op<Pl> >& l, const Pr&  r)
 {
-       return l.template scale_me<typename Internal::MultiplyType<Pl, 
Pr>::type, Pl>(static_cast<typename Internal::DivideType<Pl,Pr>::type>(1)/r); 
+       return l.template scale_me<typename Internal::DivideType<Pl, Pr>::type, 
Pl>(static_cast<typename Internal::DivideType<Pl,Pr>::type>(1)/r); 
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]