]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/drul-array.hh
2003 -> 2004
[lilypond.git] / flower / include / drul-array.hh
index 75f98611956ca2494728440f1286cf7c94db32b3..8599576f6eaae8eb1a60883151de62251e874a47 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
@@ -11,6 +11,7 @@
 #define DRUL_ARRAY_HH
 
 #include "direction.hh"
+#include "real.hh"
 
 #include <assert.h>
 
@@ -24,7 +25,7 @@ struct Drul_array
   T &elem (Direction d)
     {
       assert (d==1 || d== -1);
-      return array_[(d+1)/2];
+      return array_[ (d+1)/2];
 
     }
   T &operator[] (Direction d)
@@ -34,10 +35,10 @@ struct Drul_array
   T elem (Direction d) const
     {
     assert (d==1 || d== -1);
-    return array_[(d+1)/2];
+    return array_[ (d+1)/2];
     }
   
-  T operator[]  (Direction d) const
+  T operator[] (Direction d) const
   {
     return elem (d);
   }
@@ -50,4 +51,18 @@ struct Drul_array
     }
 };
 
+template<class T>
+void
+scale_drul (Drul_array<T> * dr, T x)
+{
+  dr->elem (LEFT) *= x;
+  dr->elem (RIGHT) *= x;
+}
+
+inline Real
+linear_combination (Drul_array<Real> const &d, Real x)
+{
+  return ((1.0 - x) * Real (d.elem (LEFT))  + (x + 1.0) * Real (d.elem (RIGHT))) * 0.5;
+}
+
 #endif // DRUL_ARRAY_HH