title: Interface as arguments. How is it possible?
body: <p>Interface as arguments. How is it possible?</p>
  
  <p><a href="https://github.com/skelterjohn/go.matrix/blob/go1/matrix.go" rel="nofollow">https://github.com/skelterjohn/go.matrix/blob/go1/matrix.go</a></p>
  
  <p>This package has this interface</p>
  
  <pre><code>type MatrixRO interface {
    Nil() bool
    Rows() int
    Cols() int
    NumElements() int
    GetSize() (int, int)
    Get(i, j int) float64
  
    Plus(MatrixRO) (Matrix, error)
    Minus(MatrixRO) (Matrix, error)
    Times(MatrixRO) (Matrix, error)
  
    Det() float64
    Trace() float64
  
    String() string
  
    DenseMatrix() *DenseMatrix
    SparseMatrix() *SparseMatrix
  }
  </code></pre>
  
  <p>interface has only methods. Not data structure. 
  Then how come Plus(MatrixRO) receives the interface as arguments?
  How is it possible to operate plus even if MatrixRO does not have any data in it?</p>
  
  <p>This function also receives </p>
  
  <pre><code>  func String(A MatrixRO) string {
  </code></pre>
  
  <p>MatrixRO as an argument.</p>
  
  <p>How it is possible? Is is because of the line </p>
  
  <pre><code>DenseMatrix() *DenseMatrix
  SparseMatrix() *SparseMatrix
  </code></pre>
  
  <p>? If it needs to embed something, shouldn't it be like the following?</p>
  
  <pre><code>DenseMatrix
  SparseMatrix
  </code></pre>
  
  <p>p.s. DenseMatrix and SparseMatrix structures are defined like this:</p>
  
  <pre><code>type DenseMatrix struct {
    matrix
    elements []float64
    step int
  }
  </code></pre>