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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
// Code generated by genlib2. DO NOT EDIT.
package tensor
import (
"testing"
"github.com/stretchr/testify/assert"
)
var onesTests = []struct {
of Dtype
shape Shape
correct interface{}
}{
{Int, ScalarShape(), int(1)},
{Int, Shape{2, 2}, []int{1, 1, 1, 1}},
{Int8, ScalarShape(), int8(1)},
{Int8, Shape{2, 2}, []int8{1, 1, 1, 1}},
{Int16, ScalarShape(), int16(1)},
{Int16, Shape{2, 2}, []int16{1, 1, 1, 1}},
{Int32, ScalarShape(), int32(1)},
{Int32, Shape{2, 2}, []int32{1, 1, 1, 1}},
{Int64, ScalarShape(), int64(1)},
{Int64, Shape{2, 2}, []int64{1, 1, 1, 1}},
{Uint, ScalarShape(), uint(1)},
{Uint, Shape{2, 2}, []uint{1, 1, 1, 1}},
{Uint8, ScalarShape(), uint8(1)},
{Uint8, Shape{2, 2}, []uint8{1, 1, 1, 1}},
{Uint16, ScalarShape(), uint16(1)},
{Uint16, Shape{2, 2}, []uint16{1, 1, 1, 1}},
{Uint32, ScalarShape(), uint32(1)},
{Uint32, Shape{2, 2}, []uint32{1, 1, 1, 1}},
{Uint64, ScalarShape(), uint64(1)},
{Uint64, Shape{2, 2}, []uint64{1, 1, 1, 1}},
{Float32, ScalarShape(), float32(1)},
{Float32, Shape{2, 2}, []float32{1, 1, 1, 1}},
{Float64, ScalarShape(), float64(1)},
{Float64, Shape{2, 2}, []float64{1, 1, 1, 1}},
{Complex64, ScalarShape(), complex64(1)},
{Complex64, Shape{2, 2}, []complex64{1, 1, 1, 1}},
{Complex128, ScalarShape(), complex128(1)},
{Complex128, Shape{2, 2}, []complex128{1, 1, 1, 1}},
{Bool, ScalarShape(), true},
{Bool, Shape{2, 2}, []bool{true, true, true, true}},
}
func TestOnes(t *testing.T) {
assert := assert.New(t)
for _, ot := range onesTests {
T := Ones(ot.of, ot.shape...)
assert.True(ot.shape.Eq(T.Shape()))
assert.Equal(ot.correct, T.Data())
}
}
// yes, it's a pun on eye tests, stop asking and go see your optometrist
var eyeTests = []struct {
E Dtype
R, C, K int
correct interface{}
}{
{Int, 4, 4, 0, []int{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Int, 4, 4, 1, []int{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Int, 4, 4, 2, []int{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int, 4, 4, 3, []int{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int, 4, 4, 4, []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int, 4, 4, -1, []int{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Int, 4, 4, -2, []int{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Int, 4, 4, -3, []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1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, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Int8, 4, 5, -1, []int8{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Int16, 4, 4, 0, []int16{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Int16, 4, 4, 1, []int16{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Int16, 4, 4, 2, []int16{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int16, 4, 4, 3, []int16{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int16, 4, 4, 4, []int16{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int16, 4, 4, -1, []int16{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Int16, 4, 4, -2, []int16{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Int16, 4, 4, -3, []int16{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Int16, 4, 4, -4, []int16{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int16, 4, 5, 0, []int16{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Int16, 4, 5, 1, []int16{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Int16, 4, 5, -1, []int16{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Int32, 4, 4, 0, []int32{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Int32, 4, 4, 1, []int32{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Int32, 4, 4, 2, []int32{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int32, 4, 4, 3, []int32{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int32, 4, 4, 4, []int32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int32, 4, 4, -1, []int32{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Int32, 4, 4, -2, []int32{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Int32, 4, 4, -3, []int32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Int32, 4, 4, -4, []int32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int32, 4, 5, 0, []int32{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Int32, 4, 5, 1, []int32{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Int32, 4, 5, -1, []int32{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Int64, 4, 4, 0, []int64{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Int64, 4, 4, 1, []int64{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Int64, 4, 4, 2, []int64{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int64, 4, 4, 3, []int64{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int64, 4, 4, 4, []int64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int64, 4, 4, -1, []int64{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Int64, 4, 4, -2, []int64{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Int64, 4, 4, -3, []int64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Int64, 4, 4, -4, []int64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Int64, 4, 5, 0, []int64{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Int64, 4, 5, 1, []int64{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Int64, 4, 5, -1, []int64{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Uint, 4, 4, 0, []uint{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Uint, 4, 4, 1, []uint{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Uint, 4, 4, 2, []uint{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint, 4, 4, 3, []uint{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint, 4, 4, 4, []uint{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint, 4, 4, -1, []uint{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Uint, 4, 4, -2, []uint{0, 0, 0,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, 0, 0}},
{Uint8, 4, 5, 0, []uint8{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Uint8, 4, 5, 1, []uint8{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Uint8, 4, 5, -1, []uint8{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Uint16, 4, 4, 0, []uint16{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Uint16, 4, 4, 1, []uint16{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Uint16, 4, 4, 2, []uint16{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint16, 4, 4, 3, []uint16{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint16, 4, 4, 4, []uint16{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint16, 4, 4, -1, []uint16{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Uint16, 4, 4, -2, []uint16{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Uint16, 4, 4, -3, []uint16{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Uint16, 4, 4, -4, []uint16{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint16, 4, 5, 0, []uint16{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Uint16, 4, 5, 1, []uint16{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Uint16, 4, 5, -1, []uint16{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Uint32, 4, 4, 0, []uint32{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Uint32, 4, 4, 1, []uint32{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Uint32, 4, 4, 2, []uint32{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint32, 4, 4, 3, []uint32{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint32, 4, 4, 4, []uint32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint32, 4, 4, -1, []uint32{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Uint32, 4, 4, -2, []uint32{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Uint32, 4, 4, -3, []uint32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Uint32, 4, 4, -4, []uint32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint32, 4, 5, 0, []uint32{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Uint32, 4, 5, 1, []uint32{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Uint32, 4, 5, -1, []uint32{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Uint64, 4, 4, 0, []uint64{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Uint64, 4, 4, 1, []uint64{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Uint64, 4, 4, 2, []uint64{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint64, 4, 4, 3, []uint64{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint64, 4, 4, 4, []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint64, 4, 4, -1, []uint64{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Uint64, 4, 4, -2, []uint64{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Uint64, 4, 4, -3, []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Uint64, 4, 4, -4, []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Uint64, 4, 5, 0, []uint64{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Uint64, 4, 5, 1, []uint64{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Uint64, 4, 5, -1, []uint64{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Float32, 4, 4, 0, []float32{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Float32, 4, 4, 1, []float32{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Float32, 4, 4, 2, []float32{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Float32, 4, 4, 3, []float32{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Float32, 4, 4, 4, []float32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Float32, 4, 4, -1, []float32{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Float32, 4, 4, -2, []float32{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Float32, 4, 4, -3, []float32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Float32, 4, 4, -4, []float32{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Float32, 4, 5, 0, []float32{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Float32, 4, 5, 1, []float32{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Float32, 4, 5, -1, []float32{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Float64, 4, 4, 0, []float64{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Float64, 4, 4, 1, []float64{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Float64, 4, 4, 2, []float64{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Float64, 4, 4, 3, []float64{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Float64, 4, 4, 4, []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Float64, 4, 4, -1, []float64{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Float64, 4, 4, -2, []float64{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Float64, 4, 4, -3, []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Float64, 4, 4, -4, []float64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Float64, 4, 5, 0, []float64{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Float64, 4, 5, 1, []float64{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Float64, 4, 5, -1, []float64{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Complex64, 4, 4, 0, []complex64{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Complex64, 4, 4, 1, []complex64{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Complex64, 4, 4, 2, []complex64{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Complex64, 4, 4, 3, []complex64{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Complex64, 4, 4, 4, []complex64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Complex64, 4, 4, -1, []complex64{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Complex64, 4, 4, -2, []complex64{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Complex64, 4, 4, -3, []complex64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Complex64, 4, 4, -4, []complex64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Complex64, 4, 5, 0, []complex64{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Complex64, 4, 5, 1, []complex64{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Complex64, 4, 5, -1, []complex64{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
{Complex128, 4, 4, 0, []complex128{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
{Complex128, 4, 4, 1, []complex128{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
{Complex128, 4, 4, 2, []complex128{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}},
{Complex128, 4, 4, 3, []complex128{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Complex128, 4, 4, 4, []complex128{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Complex128, 4, 4, -1, []complex128{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
{Complex128, 4, 4, -2, []complex128{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
{Complex128, 4, 4, -3, []complex128{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
{Complex128, 4, 4, -4, []complex128{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{Complex128, 4, 5, 0, []complex128{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}},
{Complex128, 4, 5, 1, []complex128{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}},
{Complex128, 4, 5, -1, []complex128{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}},
}
func TestI(t *testing.T) {
assert := assert.New(t)
var T Tensor
for i, it := range eyeTests {
T = I(it.E, it.R, it.C, it.K)
assert.True(Shape{it.R, it.C}.Eq(T.Shape()))
assert.Equal(it.correct, T.Data(), "Test %d-R: %d, C: %d K: %d", i, it.R, it.C, it.K)
}
}
|