aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gonum.org/v1/gonum/blas/cblas128/conv_hermitian.go
blob: 51c3a5777bb654f6045f3e361a627f7dd7dee032 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Code generated by "go generate gonum.org/v1/gonum/blas”; DO NOT EDIT.

// Copyright ©2015 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package cblas128

import "gonum.org/v1/gonum/blas"

// HermitianCols represents a matrix using the conventional column-major storage scheme.
type HermitianCols Hermitian

// From fills the receiver with elements from a. The receiver
// must have the same dimensions and uplo as a and have adequate
// backing data storage.
func (t HermitianCols) From(a Hermitian) {
	if t.N != a.N {
		panic("cblas128: mismatched dimension")
	}
	if t.Uplo != a.Uplo {
		panic("cblas128: mismatched BLAS uplo")
	}
	switch a.Uplo {
	default:
		panic("cblas128: bad BLAS uplo")
	case blas.Upper:
		for i := 0; i < a.N; i++ {
			for j := i; j < a.N; j++ {
				t.Data[i+j*t.Stride] = a.Data[i*a.Stride+j]
			}
		}
	case blas.Lower:
		for i := 0; i < a.N; i++ {
			for j := 0; j <= i; j++ {
				t.Data[i+j*t.Stride] = a.Data[i*a.Stride+j]
			}
		}
	}
}

// From fills the receiver with elements from a. The receiver
// must have the same dimensions and uplo as a and have adequate
// backing data storage.
func (t Hermitian) From(a HermitianCols) {
	if t.N != a.N {
		panic("cblas128: mismatched dimension")
	}
	if t.Uplo != a.Uplo {
		panic("cblas128: mismatched BLAS uplo")
	}
	switch a.Uplo {
	default:
		panic("cblas128: bad BLAS uplo")
	case blas.Upper:
		for i := 0; i < a.N; i++ {
			for j := i; j < a.N; j++ {
				t.Data[i*t.Stride+j] = a.Data[i+j*a.Stride]
			}
		}
	case blas.Lower:
		for i := 0; i < a.N; i++ {
			for j := 0; j <= i; j++ {
				t.Data[i*t.Stride+j] = a.Data[i+j*a.Stride]
			}
		}
	}
}

// HermitianBandCols represents an Hermitian matrix using the band column-major storage scheme.
type HermitianBandCols HermitianBand

// From fills the receiver with elements from a. The receiver
// must have the same dimensions, bandwidth and uplo as a and
// have adequate backing data storage.
func (t HermitianBandCols) From(a HermitianBand) {
	if t.N != a.N {
		panic("cblas128: mismatched dimension")
	}
	if t.K != a.K {
		panic("cblas128: mismatched bandwidth")
	}
	if a.Stride < a.K+1 {
		panic("cblas128: short stride for source")
	}
	if t.Stride < t.K+1 {
		panic("cblas128: short stride for destination")
	}
	if t.Uplo != a.Uplo {
		panic("cblas128: mismatched BLAS uplo")
	}
	dst := BandCols{
		Rows: t.N, Cols: t.N,
		Stride: t.Stride,
		Data:   t.Data,
	}
	src := Band{
		Rows: a.N, Cols: a.N,
		Stride: a.Stride,
		Data:   a.Data,
	}
	switch a.Uplo {
	default:
		panic("cblas128: bad BLAS uplo")
	case blas.Upper:
		dst.KU = t.K
		src.KU = a.K
	case blas.Lower:
		dst.KL = t.K
		src.KL = a.K
	}
	dst.From(src)
}

// From fills the receiver with elements from a. The receiver
// must have the same dimensions, bandwidth and uplo as a and
// have adequate backing data storage.
func (t HermitianBand) From(a HermitianBandCols) {
	if t.N != a.N {
		panic("cblas128: mismatched dimension")
	}
	if t.K != a.K {
		panic("cblas128: mismatched bandwidth")
	}
	if a.Stride < a.K+1 {
		panic("cblas128: short stride for source")
	}
	if t.Stride < t.K+1 {
		panic("cblas128: short stride for destination")
	}
	if t.Uplo != a.Uplo {
		panic("cblas128: mismatched BLAS uplo")
	}
	dst := Band{
		Rows: t.N, Cols: t.N,
		Stride: t.Stride,
		Data:   t.Data,
	}
	src := BandCols{
		Rows: a.N, Cols: a.N,
		Stride: a.Stride,
		Data:   a.Data,
	}
	switch a.Uplo {
	default:
		panic("cblas128: bad BLAS uplo")
	case blas.Upper:
		dst.KU = t.K
		src.KU = a.K
	case blas.Lower:
		dst.KL = t.K
		src.KL = a.K
	}
	dst.From(src)
}