]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.46.jcn1
authorfred <fred>
Wed, 26 Mar 1997 21:21:35 +0000 (21:21 +0000)
committerfred <fred>
Wed, 26 Mar 1997 21:21:35 +0000 (21:21 +0000)
flower/include/matrix-storage.hh [new file with mode: 0644]

diff --git a/flower/include/matrix-storage.hh b/flower/include/matrix-storage.hh
new file mode 100644 (file)
index 0000000..8e34d60
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+  matrix-storage.hh -- declare Matrix_storage
+
+  source file of the Flower Library
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef MATRIX_STORAGE_HH
+#define MATRIX_STORAGE_HH
+
+#include "varray.hh"
+#include "real.hh"
+#include "class-name.hh"
+
+/** 
+
+    base class for interface with matrix storageclasses.  There are no
+    iterators for matrixclasses, since matrices are (like arrays)
+    explicitly int-indexed.
+
+    Iteration is provided by *_next, *_ok, which update and check both
+    index variables simultaneously.
+
+    TODO
+    determine type of product matrix.
+
+*/
+class Matrix_storage {
+    
+
+public:
+    /// check invariants
+    virtual void OK() const=0;
+    
+    /// height of matrix
+    virtual int rows() const = 0;
+
+    /// width of matrix
+    virtual int cols() const = 0;
+      
+    /**  set the size. contents lost.       
+      PRE
+      i >=0, j>=0
+    */
+    virtual void set_size(int rows, int cols) = 0;
+    /**set the size to square dimen. contents lost
+      PRE
+      i>=0
+    */
+    virtual void set_size(int i) = 0;
+     /**set the size to i.
+
+      keep contents. If enlarged contents unspecified
+        
+      PRE
+      i>=0, j>=0
+    
+    */
+    virtual void resize(int rows, int cols ) = 0;
+  /**    
+    set the size to square dimen. contents kept
+    Keep contents. If enlarged contents are unspecified
+    
+    PRE
+    i>=0  
+    */
+    virtual void resize(int i) = 0;
+  
+    
+        /**
+    access an element.
+
+    Generate an errormessage, if this happens
+    in the 0-part of a sparse matrix.
+    */
+
+    virtual Real& elem(int i,int j) = 0;
+
+    /// access a element, no modify
+    virtual Real const & elem(int i, int j) const = 0;
+
+    virtual Array<Real> row(int i) const = 0;
+    virtual Array<Real> column(int j) const = 0;
+
+    
+    /**
+    add a row to the matrix before  row k. Contents
+    of added row are unspecified
+
+      0 <= k <= rows()
+    */
+    virtual void insert_row(int k)=0;
+
+    
+      /**
+      delete a row from this matrix.
+
+      PRE
+      0 <= k < rows();
+    */
+    virtual void delete_row(int k)=0;
+        virtual void delete_column(int k)=0;
+    virtual ~Matrix_storage() { }
+    virtual Matrix_storage *clone()=0;
+
+
+    
+    /**
+      at end of matrix?. when doing loop
+
+      for(i=0; i<h; i++)
+        for(j=0; j<w; j++)
+          ..
+
+    */
+    virtual bool mult_ok(int i, int j) const=0;
+
+    /**
+      walk through matrix (regular multiply).
+      get next j for row i, or get next row i and reset j.
+      this will make sparse matrix implementation easy.
+    
+      PRE
+      mult_ok(i,j)
+     */
+    virtual void mult_next(int &i, int &j) const  = 0;
+
+/**
+      valid matrix entry. return false if at end of row
+    */
+    virtual bool trans_ok(int i, int j) const=0;
+
+    /**
+      walk through matrix (transposed multiply).
+      Get next i (for column j)
+    
+      PRE
+      ver_ok(i,j)
+     */
+
+    virtual void trans_next(int &i, int &j) const  = 0;
+    /// generate a "Full_storage" matrix    
+    static Matrix_storage *get_full(int n, int m);
+    
+
+    virtual bool try_right_multiply(Matrix_storage *dest, 
+                                   const Matrix_storage *fact) ;
+    /**
+      RTTI.
+     */
+    NAME_MEMBERS(Matrix_storage);
+};
+
+
+
+inline bool
+Matrix_storage::try_right_multiply(Matrix_storage *, 
+                                   const Matrix_storage *)
+{
+    return false;
+}
+#endif // MATRIX_STORAGE_HH
+