-
Notifications
You must be signed in to change notification settings - Fork 6
/
all_complex.go
93 lines (79 loc) · 2.11 KB
/
all_complex.go
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
// Copyright (c) Harri Rautila, 2012
// This file is part of github.com/hrautila/linalg/blas package.
// It is free software, distributed under the terms of GNU Lesser General Public
// License Version 3, or any later version. See the COPYING tile included in this archive.
package blas
import (
"github.com/hrautila/linalg"
"github.com/hrautila/matrix"
//"errors"
)
// Calculate norm2(X) for ComplexMatrix. Valid options are: offset, inc, N.
// See function Nrm2.
func Nrm2Complex(X *matrix.ComplexMatrix, opts ...linalg.Option) (v float64, err error) {
v = 0.0
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fnrm2, X, nil)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
Xa := X.ComplexArray()
v = dznrm2(ind.Nx, Xa[ind.OffsetX:], ind.IncX)
return
}
// Calculate sum(X) for complex matrix. Valid options are: offset, inc, N.
// See function Asum.
func AsumComplex(X *matrix.ComplexMatrix, opts ...linalg.Option) (v float64, err error) {
v = 0.0
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fasum, X, nil)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
Xa := X.ComplexArray()
v = dzasum(ind.Nx, Xa[ind.OffsetX:], ind.IncX)
return
}
// Calculate X.T * Y for complex matrix.
// See function Dot.
func DotuComplex(X, Y *matrix.ComplexMatrix, opts ...linalg.Option) (v complex128, err error) {
v = 0.0
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fdot, X, Y)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
Xa := X.ComplexArray()
Ya := Y.ComplexArray()
v = zdotu(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY)
return
}
// Calculate conjugate X.T * Y for complex matrix.
// See function Dotc.
func DotcComplex(X, Y *matrix.ComplexMatrix, opts ...linalg.Option) (v complex128, err error) {
v = 0.0
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fdot, X, Y)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
Xa := X.ComplexArray()
Ya := Y.ComplexArray()
v = zdotc(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY)
return
}
// Local Variables:
// tab-width: 4
// End: