github.com/gopherd/gonum@v0.0.4/mat/basictypes_test.go (about)

     1  // Copyright ©2015 The Gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package mat
     6  
     7  import "github.com/gopherd/gonum/blas/blas64"
     8  
     9  func asBasicMatrix(d *Dense) *basicMatrix              { return (*basicMatrix)(d) }
    10  func asBasicVector(d *VecDense) *basicVector           { return (*basicVector)(d) }
    11  func asBasicSymmetric(s *SymDense) *basicSymmetric     { return (*basicSymmetric)(s) }
    12  func asBasicTriangular(t *TriDense) *basicTriangular   { return (*basicTriangular)(t) }
    13  func asBasicBanded(b *BandDense) *basicBanded          { return (*basicBanded)(b) }
    14  func asBasicSymBanded(s *SymBandDense) *basicSymBanded { return (*basicSymBanded)(s) }
    15  func asBasicTriBanded(t *TriBandDense) *basicTriBanded { return (*basicTriBanded)(t) }
    16  func asBasicDiagonal(d *DiagDense) *basicDiagonal      { return (*basicDiagonal)(d) }
    17  
    18  type basicMatrix Dense
    19  
    20  var _ Matrix = &basicMatrix{}
    21  
    22  func (m *basicMatrix) At(r, c int) float64 { return (*Dense)(m).At(r, c) }
    23  func (m *basicMatrix) Dims() (r, c int)    { return (*Dense)(m).Dims() }
    24  func (m *basicMatrix) T() Matrix           { return Transpose{m} }
    25  
    26  type rawMatrix struct {
    27  	*basicMatrix
    28  }
    29  
    30  func (a *rawMatrix) RawMatrix() blas64.General {
    31  	return a.mat
    32  }
    33  
    34  type basicVector VecDense
    35  
    36  var _ Vector = &basicVector{}
    37  
    38  func (v *basicVector) At(r, c int) float64 { return (*VecDense)(v).At(r, c) }
    39  func (v *basicVector) Dims() (r, c int)    { return (*VecDense)(v).Dims() }
    40  func (v *basicVector) T() Matrix           { return Transpose{v} }
    41  func (v *basicVector) AtVec(i int) float64 { return (*VecDense)(v).AtVec(i) }
    42  func (v *basicVector) Len() int            { return (*VecDense)(v).Len() }
    43  
    44  type rawVector struct {
    45  	*basicVector
    46  }
    47  
    48  func (v *rawVector) RawVector() blas64.Vector {
    49  	return v.mat
    50  }
    51  
    52  type basicSymmetric SymDense
    53  
    54  var _ Symmetric = &basicSymmetric{}
    55  
    56  func (m *basicSymmetric) At(r, c int) float64 { return (*SymDense)(m).At(r, c) }
    57  func (m *basicSymmetric) Dims() (r, c int)    { return (*SymDense)(m).Dims() }
    58  func (m *basicSymmetric) T() Matrix           { return m }
    59  func (m *basicSymmetric) SymmetricDim() int   { return (*SymDense)(m).SymmetricDim() }
    60  
    61  type basicTriangular TriDense
    62  
    63  var _ Triangular = &basicTriangular{}
    64  
    65  func (m *basicTriangular) At(r, c int) float64      { return (*TriDense)(m).At(r, c) }
    66  func (m *basicTriangular) Dims() (r, c int)         { return (*TriDense)(m).Dims() }
    67  func (m *basicTriangular) T() Matrix                { return Transpose{m} }
    68  func (m *basicTriangular) Triangle() (int, TriKind) { return (*TriDense)(m).Triangle() }
    69  func (m *basicTriangular) TTri() Triangular         { return TransposeTri{m} }
    70  
    71  type basicBanded BandDense
    72  
    73  var _ Banded = &basicBanded{}
    74  
    75  func (m *basicBanded) At(r, c int) float64     { return (*BandDense)(m).At(r, c) }
    76  func (m *basicBanded) Dims() (r, c int)        { return (*BandDense)(m).Dims() }
    77  func (m *basicBanded) T() Matrix               { return Transpose{m} }
    78  func (m *basicBanded) Bandwidth() (kl, ku int) { return (*BandDense)(m).Bandwidth() }
    79  func (m *basicBanded) TBand() Banded           { return TransposeBand{m} }
    80  
    81  type basicSymBanded SymBandDense
    82  
    83  var _ SymBanded = &basicSymBanded{}
    84  
    85  func (m *basicSymBanded) At(r, c int) float64     { return (*SymBandDense)(m).At(r, c) }
    86  func (m *basicSymBanded) Dims() (r, c int)        { return (*SymBandDense)(m).Dims() }
    87  func (m *basicSymBanded) T() Matrix               { return m }
    88  func (m *basicSymBanded) Bandwidth() (kl, ku int) { return (*SymBandDense)(m).Bandwidth() }
    89  func (m *basicSymBanded) TBand() Banded           { return m }
    90  func (m *basicSymBanded) SymmetricDim() int       { return (*SymBandDense)(m).SymmetricDim() }
    91  func (m *basicSymBanded) SymBand() (n, k int)     { return (*SymBandDense)(m).SymBand() }
    92  
    93  type basicTriBanded TriBandDense
    94  
    95  var _ TriBanded = &basicTriBanded{}
    96  
    97  func (m *basicTriBanded) At(r, c int) float64               { return (*TriBandDense)(m).At(r, c) }
    98  func (m *basicTriBanded) Dims() (r, c int)                  { return (*TriBandDense)(m).Dims() }
    99  func (m *basicTriBanded) T() Matrix                         { return Transpose{m} }
   100  func (m *basicTriBanded) Triangle() (int, TriKind)          { return (*TriBandDense)(m).Triangle() }
   101  func (m *basicTriBanded) TTri() Triangular                  { return TransposeTri{m} }
   102  func (m *basicTriBanded) Bandwidth() (kl, ku int)           { return (*TriBandDense)(m).Bandwidth() }
   103  func (m *basicTriBanded) TBand() Banded                     { return TransposeBand{m} }
   104  func (m *basicTriBanded) TriBand() (n, k int, kind TriKind) { return (*TriBandDense)(m).TriBand() }
   105  func (m *basicTriBanded) TTriBand() TriBanded               { return TransposeTriBand{m} }
   106  
   107  type basicDiagonal DiagDense
   108  
   109  var _ Diagonal = &basicDiagonal{}
   110  
   111  func (m *basicDiagonal) At(r, c int) float64               { return (*DiagDense)(m).At(r, c) }
   112  func (m *basicDiagonal) Dims() (r, c int)                  { return (*DiagDense)(m).Dims() }
   113  func (m *basicDiagonal) T() Matrix                         { return Transpose{m} }
   114  func (m *basicDiagonal) Diag() int                         { return (*DiagDense)(m).Diag() }
   115  func (m *basicDiagonal) SymmetricDim() int                 { return (*DiagDense)(m).SymmetricDim() }
   116  func (m *basicDiagonal) SymBand() (n, k int)               { return (*DiagDense)(m).SymBand() }
   117  func (m *basicDiagonal) Bandwidth() (kl, ku int)           { return (*DiagDense)(m).Bandwidth() }
   118  func (m *basicDiagonal) TBand() Banded                     { return TransposeBand{m} }
   119  func (m *basicDiagonal) Triangle() (int, TriKind)          { return (*DiagDense)(m).Triangle() }
   120  func (m *basicDiagonal) TTri() Triangular                  { return TransposeTri{m} }
   121  func (m *basicDiagonal) TriBand() (n, k int, kind TriKind) { return (*DiagDense)(m).TriBand() }
   122  func (m *basicDiagonal) TTriBand() TriBanded               { return TransposeTriBand{m} }