github.com/gopherd/gonum@v0.0.4/blas/blas32/conv_symmetric.go (about) 1 // Code generated by "go generate github.com/gopherd/gonum/blas”; DO NOT EDIT. 2 3 // Copyright ©2015 The Gonum Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 package blas32 8 9 import "github.com/gopherd/gonum/blas" 10 11 // SymmetricCols represents a matrix using the conventional column-major storage scheme. 12 type SymmetricCols Symmetric 13 14 // From fills the receiver with elements from a. The receiver 15 // must have the same dimensions and uplo as a and have adequate 16 // backing data storage. 17 func (t SymmetricCols) From(a Symmetric) { 18 if t.N != a.N { 19 panic("blas32: mismatched dimension") 20 } 21 if t.Uplo != a.Uplo { 22 panic("blas32: mismatched BLAS uplo") 23 } 24 switch a.Uplo { 25 default: 26 panic("blas32: bad BLAS uplo") 27 case blas.Upper: 28 for i := 0; i < a.N; i++ { 29 for j := i; j < a.N; j++ { 30 t.Data[i+j*t.Stride] = a.Data[i*a.Stride+j] 31 } 32 } 33 case blas.Lower: 34 for i := 0; i < a.N; i++ { 35 for j := 0; j <= i; j++ { 36 t.Data[i+j*t.Stride] = a.Data[i*a.Stride+j] 37 } 38 } 39 } 40 } 41 42 // From fills the receiver with elements from a. The receiver 43 // must have the same dimensions and uplo as a and have adequate 44 // backing data storage. 45 func (t Symmetric) From(a SymmetricCols) { 46 if t.N != a.N { 47 panic("blas32: mismatched dimension") 48 } 49 if t.Uplo != a.Uplo { 50 panic("blas32: mismatched BLAS uplo") 51 } 52 switch a.Uplo { 53 default: 54 panic("blas32: bad BLAS uplo") 55 case blas.Upper: 56 for i := 0; i < a.N; i++ { 57 for j := i; j < a.N; j++ { 58 t.Data[i*t.Stride+j] = a.Data[i+j*a.Stride] 59 } 60 } 61 case blas.Lower: 62 for i := 0; i < a.N; i++ { 63 for j := 0; j <= i; j++ { 64 t.Data[i*t.Stride+j] = a.Data[i+j*a.Stride] 65 } 66 } 67 } 68 } 69 70 // SymmetricBandCols represents a symmetric matrix using the band column-major storage scheme. 71 type SymmetricBandCols SymmetricBand 72 73 // From fills the receiver with elements from a. The receiver 74 // must have the same dimensions, bandwidth and uplo as a and 75 // have adequate backing data storage. 76 func (t SymmetricBandCols) From(a SymmetricBand) { 77 if t.N != a.N { 78 panic("blas32: mismatched dimension") 79 } 80 if t.K != a.K { 81 panic("blas32: mismatched bandwidth") 82 } 83 if a.Stride < a.K+1 { 84 panic("blas32: short stride for source") 85 } 86 if t.Stride < t.K+1 { 87 panic("blas32: short stride for destination") 88 } 89 if t.Uplo != a.Uplo { 90 panic("blas32: mismatched BLAS uplo") 91 } 92 dst := BandCols{ 93 Rows: t.N, Cols: t.N, 94 Stride: t.Stride, 95 Data: t.Data, 96 } 97 src := Band{ 98 Rows: a.N, Cols: a.N, 99 Stride: a.Stride, 100 Data: a.Data, 101 } 102 switch a.Uplo { 103 default: 104 panic("blas32: bad BLAS uplo") 105 case blas.Upper: 106 dst.KU = t.K 107 src.KU = a.K 108 case blas.Lower: 109 dst.KL = t.K 110 src.KL = a.K 111 } 112 dst.From(src) 113 } 114 115 // From fills the receiver with elements from a. The receiver 116 // must have the same dimensions, bandwidth and uplo as a and 117 // have adequate backing data storage. 118 func (t SymmetricBand) From(a SymmetricBandCols) { 119 if t.N != a.N { 120 panic("blas32: mismatched dimension") 121 } 122 if t.K != a.K { 123 panic("blas32: mismatched bandwidth") 124 } 125 if a.Stride < a.K+1 { 126 panic("blas32: short stride for source") 127 } 128 if t.Stride < t.K+1 { 129 panic("blas32: short stride for destination") 130 } 131 if t.Uplo != a.Uplo { 132 panic("blas32: mismatched BLAS uplo") 133 } 134 dst := Band{ 135 Rows: t.N, Cols: t.N, 136 Stride: t.Stride, 137 Data: t.Data, 138 } 139 src := BandCols{ 140 Rows: a.N, Cols: a.N, 141 Stride: a.Stride, 142 Data: a.Data, 143 } 144 switch a.Uplo { 145 default: 146 panic("blas32: bad BLAS uplo") 147 case blas.Upper: 148 dst.KU = t.K 149 src.KU = a.K 150 case blas.Lower: 151 dst.KL = t.K 152 src.KL = a.K 153 } 154 dst.From(src) 155 }