| 1 |
// Code generated by genlib2. DO NOT EDIT. |
| 2 |
|
| 3 |
package execution |
| 4 |
|
| 5 |
import "unsafe" |
| 6 |
|
| 7 |
func ReduceB(f func(a, b bool) bool, def bool, l ...bool) (retVal bool) { |
| 8 |
retVal = def |
| 9 |
if len(l) == 0 { |
| 10 |
return |
| 11 |
} |
| 12 |
|
| 13 |
for _, v := range l { |
| 14 |
retVal = f(retVal, v) |
| 15 |
} |
| 16 |
return |
| 17 |
} |
| 18 |
|
| 19 |
func ReduceI(f func(a, b int) int, def int, l ...int) (retVal int) { |
| 20 |
retVal = def |
| 21 |
if len(l) == 0 { |
| 22 |
return |
| 23 |
} |
| 24 |
|
| 25 |
for _, v := range l { |
| 26 |
retVal = f(retVal, v) |
| 27 |
} |
| 28 |
return |
| 29 |
} |
| 30 |
|
| 31 |
func ReduceI8(f func(a, b int8) int8, def int8, l ...int8) (retVal int8) { |
| 32 |
retVal = def |
| 33 |
if len(l) == 0 { |
| 34 |
return |
| 35 |
} |
| 36 |
|
| 37 |
for _, v := range l { |
| 38 |
retVal = f(retVal, v) |
| 39 |
} |
| 40 |
return |
| 41 |
} |
| 42 |
|
| 43 |
func ReduceI16(f func(a, b int16) int16, def int16, l ...int16) (retVal int16) { |
| 44 |
retVal = def |
| 45 |
if len(l) == 0 { |
| 46 |
return |
| 47 |
} |
| 48 |
|
| 49 |
for _, v := range l { |
| 50 |
retVal = f(retVal, v) |
| 51 |
} |
| 52 |
return |
| 53 |
} |
| 54 |
|
| 55 |
func ReduceI32(f func(a, b int32) int32, def int32, l ...int32) (retVal int32) { |
| 56 |
retVal = def |
| 57 |
if len(l) == 0 { |
| 58 |
return |
| 59 |
} |
| 60 |
|
| 61 |
for _, v := range l { |
| 62 |
retVal = f(retVal, v) |
| 63 |
} |
| 64 |
return |
| 65 |
} |
| 66 |
|
| 67 |
func ReduceI64(f func(a, b int64) int64, def int64, l ...int64) (retVal int64) { |
| 68 |
retVal = def |
| 69 |
if len(l) == 0 { |
| 70 |
return |
| 71 |
} |
| 72 |
|
| 73 |
for _, v := range l { |
| 74 |
retVal = f(retVal, v) |
| 75 |
} |
| 76 |
return |
| 77 |
} |
| 78 |
|
| 79 |
func ReduceU(f func(a, b uint) uint, def uint, l ...uint) (retVal uint) { |
| 80 |
retVal = def |
| 81 |
if len(l) == 0 { |
| 82 |
return |
| 83 |
} |
| 84 |
|
| 85 |
for _, v := range l { |
| 86 |
retVal = f(retVal, v) |
| 87 |
} |
| 88 |
return |
| 89 |
} |
| 90 |
|
| 91 |
func ReduceU8(f func(a, b uint8) uint8, def uint8, l ...uint8) (retVal uint8) { |
| 92 |
retVal = def |
| 93 |
if len(l) == 0 { |
| 94 |
return |
| 95 |
} |
| 96 |
|
| 97 |
for _, v := range l { |
| 98 |
retVal = f(retVal, v) |
| 99 |
} |
| 100 |
return |
| 101 |
} |
| 102 |
|
| 103 |
func ReduceU16(f func(a, b uint16) uint16, def uint16, l ...uint16) (retVal uint16) { |
| 104 |
retVal = def |
| 105 |
if len(l) == 0 { |
| 106 |
return |
| 107 |
} |
| 108 |
|
| 109 |
for _, v := range l { |
| 110 |
retVal = f(retVal, v) |
| 111 |
} |
| 112 |
return |
| 113 |
} |
| 114 |
|
| 115 |
func ReduceU32(f func(a, b uint32) uint32, def uint32, l ...uint32) (retVal uint32) { |
| 116 |
retVal = def |
| 117 |
if len(l) == 0 { |
| 118 |
return |
| 119 |
} |
| 120 |
|
| 121 |
for _, v := range l { |
| 122 |
retVal = f(retVal, v) |
| 123 |
} |
| 124 |
return |
| 125 |
} |
| 126 |
|
| 127 |
func ReduceU64(f func(a, b uint64) uint64, def uint64, l ...uint64) (retVal uint64) { |
| 128 |
retVal = def |
| 129 |
if len(l) == 0 { |
| 130 |
return |
| 131 |
} |
| 132 |
|
| 133 |
for _, v := range l { |
| 134 |
retVal = f(retVal, v) |
| 135 |
} |
| 136 |
return |
| 137 |
} |
| 138 |
|
| 139 |
func ReduceUintptr(f func(a, b uintptr) uintptr, def uintptr, l ...uintptr) (retVal uintptr) { |
| 140 |
retVal = def |
| 141 |
if len(l) == 0 { |
| 142 |
return |
| 143 |
} |
| 144 |
|
| 145 |
for _, v := range l { |
| 146 |
retVal = f(retVal, v) |
| 147 |
} |
| 148 |
return |
| 149 |
} |
| 150 |
|
| 151 |
func ReduceF32(f func(a, b float32) float32, def float32, l ...float32) (retVal float32) { |
| 152 |
retVal = def |
| 153 |
if len(l) == 0 { |
| 154 |
return |
| 155 |
} |
| 156 |
|
| 157 |
for _, v := range l { |
| 158 |
retVal = f(retVal, v) |
| 159 |
} |
| 160 |
return |
| 161 |
} |
| 162 |
|
| 163 |
func ReduceF64(f func(a, b float64) float64, def float64, l ...float64) (retVal float64) { |
| 164 |
retVal = def |
| 165 |
if len(l) == 0 { |
| 166 |
return |
| 167 |
} |
| 168 |
|
| 169 |
for _, v := range l { |
| 170 |
retVal = f(retVal, v) |
| 171 |
} |
| 172 |
return |
| 173 |
} |
| 174 |
|
| 175 |
func ReduceC64(f func(a, b complex64) complex64, def complex64, l ...complex64) (retVal complex64) { |
| 176 |
retVal = def |
| 177 |
if len(l) == 0 { |
| 178 |
return |
| 179 |
} |
| 180 |
|
| 181 |
for _, v := range l { |
| 182 |
retVal = f(retVal, v) |
| 183 |
} |
| 184 |
return |
| 185 |
} |
| 186 |
|
| 187 |
func ReduceC128(f func(a, b complex128) complex128, def complex128, l ...complex128) (retVal complex128) { |
| 188 |
retVal = def |
| 189 |
if len(l) == 0 { |
| 190 |
return |
| 191 |
} |
| 192 |
|
| 193 |
for _, v := range l { |
| 194 |
retVal = f(retVal, v) |
| 195 |
} |
| 196 |
return |
| 197 |
} |
| 198 |
|
| 199 |
func ReduceStr(f func(a, b string) string, def string, l ...string) (retVal string) { |
| 200 |
retVal = def |
| 201 |
if len(l) == 0 { |
| 202 |
return |
| 203 |
} |
| 204 |
|
| 205 |
for _, v := range l { |
| 206 |
retVal = f(retVal, v) |
| 207 |
} |
| 208 |
return |
| 209 |
} |
| 210 |
|
| 211 |
func ReduceUnsafePointer(f func(a, b unsafe.Pointer) unsafe.Pointer, def unsafe.Pointer, l ...unsafe.Pointer) (retVal unsafe.Pointer) { |
| 212 |
retVal = def |
| 213 |
if len(l) == 0 { |
| 214 |
return |
| 215 |
} |
| 216 |
|
| 217 |
for _, v := range l { |
| 218 |
retVal = f(retVal, v) |
| 219 |
} |
| 220 |
return |
| 221 |
} |
| 222 |
|
| 223 |
func SumI(a []int) int { |
| 224 |
var retVal int |
| 225 |
a = a[:] |
| 226 |
for _, v := range a { |
| 227 |
retVal += v |
| 228 |
} |
| 229 |
return retVal |
| 230 |
} |
| 231 |
func SumI8(a []int8) int8 { |
| 232 |
var retVal int8 |
| 233 |
a = a[:] |
| 234 |
for _, v := range a { |
| 235 |
retVal += v |
| 236 |
} |
| 237 |
return retVal |
| 238 |
} |
| 239 |
func SumI16(a []int16) int16 { |
| 240 |
var retVal int16 |
| 241 |
a = a[:] |
| 242 |
for _, v := range a { |
| 243 |
retVal += v |
| 244 |
} |
| 245 |
return retVal |
| 246 |
} |
| 247 |
func SumI32(a []int32) int32 { |
| 248 |
var retVal int32 |
| 249 |
a = a[:] |
| 250 |
for _, v := range a { |
| 251 |
retVal += v |
| 252 |
} |
| 253 |
return retVal |
| 254 |
} |
| 255 |
func SumI64(a []int64) int64 { |
| 256 |
var retVal int64 |
| 257 |
a = a[:] |
| 258 |
for _, v := range a { |
| 259 |
retVal += v |
| 260 |
} |
| 261 |
return retVal |
| 262 |
} |
| 263 |
func SumU(a []uint) uint { |
| 264 |
var retVal uint |
| 265 |
a = a[:] |
| 266 |
for _, v := range a { |
| 267 |
retVal += v |
| 268 |
} |
| 269 |
return retVal |
| 270 |
} |
| 271 |
func SumU8(a []uint8) uint8 { |
| 272 |
var retVal uint8 |
| 273 |
a = a[:] |
| 274 |
for _, v := range a { |
| 275 |
retVal += v |
| 276 |
} |
| 277 |
return retVal |
| 278 |
} |
| 279 |
func SumU16(a []uint16) uint16 { |
| 280 |
var retVal uint16 |
| 281 |
a = a[:] |
| 282 |
for _, v := range a { |
| 283 |
retVal += v |
| 284 |
} |
| 285 |
return retVal |
| 286 |
} |
| 287 |
func SumU32(a []uint32) uint32 { |
| 288 |
var retVal uint32 |
| 289 |
a = a[:] |
| 290 |
for _, v := range a { |
| 291 |
retVal += v |
| 292 |
} |
| 293 |
return retVal |
| 294 |
} |
| 295 |
func SumU64(a []uint64) uint64 { |
| 296 |
var retVal uint64 |
| 297 |
a = a[:] |
| 298 |
for _, v := range a { |
| 299 |
retVal += v |
| 300 |
} |
| 301 |
return retVal |
| 302 |
} |
| 303 |
func SumF32(a []float32) float32 { |
| 304 |
var retVal float32 |
| 305 |
a = a[:] |
| 306 |
for _, v := range a { |
| 307 |
retVal += v |
| 308 |
} |
| 309 |
return retVal |
| 310 |
} |
| 311 |
func SumF64(a []float64) float64 { |
| 312 |
var retVal float64 |
| 313 |
a = a[:] |
| 314 |
for _, v := range a { |
| 315 |
retVal += v |
| 316 |
} |
| 317 |
return retVal |
| 318 |
} |
| 319 |
func SumC64(a []complex64) complex64 { |
| 320 |
var retVal complex64 |
| 321 |
a = a[:] |
| 322 |
for _, v := range a { |
| 323 |
retVal += v |
| 324 |
} |
| 325 |
return retVal |
| 326 |
} |
| 327 |
func SumC128(a []complex128) complex128 { |
| 328 |
var retVal complex128 |
| 329 |
a = a[:] |
| 330 |
for _, v := range a { |
| 331 |
retVal += v |
| 332 |
} |
| 333 |
return retVal |
| 334 |
} |
| 335 |
func ProdI(a []int) int { |
| 336 |
if len(a) == 0 { |
| 337 |
return 0 |
| 338 |
} |
| 339 |
var retVal int = 1 |
| 340 |
a = a[:] |
| 341 |
for _, v := range a { |
| 342 |
retVal *= v |
| 343 |
} |
| 344 |
return retVal |
| 345 |
} |
| 346 |
func ProdI8(a []int8) int8 { |
| 347 |
if len(a) == 0 { |
| 348 |
return 0 |
| 349 |
} |
| 350 |
var retVal int8 = 1 |
| 351 |
a = a[:] |
| 352 |
for _, v := range a { |
| 353 |
retVal *= v |
| 354 |
} |
| 355 |
return retVal |
| 356 |
} |
| 357 |
func ProdI16(a []int16) int16 { |
| 358 |
if len(a) == 0 { |
| 359 |
return 0 |
| 360 |
} |
| 361 |
var retVal int16 = 1 |
| 362 |
a = a[:] |
| 363 |
for _, v := range a { |
| 364 |
retVal *= v |
| 365 |
} |
| 366 |
return retVal |
| 367 |
} |
| 368 |
func ProdI32(a []int32) int32 { |
| 369 |
if len(a) == 0 { |
| 370 |
return 0 |
| 371 |
} |
| 372 |
var retVal int32 = 1 |
| 373 |
a = a[:] |
| 374 |
for _, v := range a { |
| 375 |
retVal *= v |
| 376 |
} |
| 377 |
return retVal |
| 378 |
} |
| 379 |
func ProdI64(a []int64) int64 { |
| 380 |
if len(a) == 0 { |
| 381 |
return 0 |
| 382 |
} |
| 383 |
var retVal int64 = 1 |
| 384 |
a = a[:] |
| 385 |
for _, v := range a { |
| 386 |
retVal *= v |
| 387 |
} |
| 388 |
return retVal |
| 389 |
} |
| 390 |
func ProdU(a []uint) uint { |
| 391 |
if len(a) == 0 { |
| 392 |
return 0 |
| 393 |
} |
| 394 |
var retVal uint = 1 |
| 395 |
a = a[:] |
| 396 |
for _, v := range a { |
| 397 |
retVal *= v |
| 398 |
} |
| 399 |
return retVal |
| 400 |
} |
| 401 |
func ProdU8(a []uint8) uint8 { |
| 402 |
if len(a) == 0 { |
| 403 |
return 0 |
| 404 |
} |
| 405 |
var retVal uint8 = 1 |
| 406 |
a = a[:] |
| 407 |
for _, v := range a { |
| 408 |
retVal *= v |
| 409 |
} |
| 410 |
return retVal |
| 411 |
} |
| 412 |
func ProdU16(a []uint16) uint16 { |
| 413 |
if len(a) == 0 { |
| 414 |
return 0 |
| 415 |
} |
| 416 |
var retVal uint16 = 1 |
| 417 |
a = a[:] |
| 418 |
for _, v := range a { |
| 419 |
retVal *= v |
| 420 |
} |
| 421 |
return retVal |
| 422 |
} |
| 423 |
func ProdU32(a []uint32) uint32 { |
| 424 |
if len(a) == 0 { |
| 425 |
return 0 |
| 426 |
} |
| 427 |
var retVal uint32 = 1 |
| 428 |
a = a[:] |
| 429 |
for _, v := range a { |
| 430 |
retVal *= v |
| 431 |
} |
| 432 |
return retVal |
| 433 |
} |
| 434 |
func ProdU64(a []uint64) uint64 { |
| 435 |
if len(a) == 0 { |
| 436 |
return 0 |
| 437 |
} |
| 438 |
var retVal uint64 = 1 |
| 439 |
a = a[:] |
| 440 |
for _, v := range a { |
| 441 |
retVal *= v |
| 442 |
} |
| 443 |
return retVal |
| 444 |
} |
| 445 |
func ProdF32(a []float32) float32 { |
| 446 |
if len(a) == 0 { |
| 447 |
return 0 |
| 448 |
} |
| 449 |
var retVal float32 = 1 |
| 450 |
a = a[:] |
| 451 |
for _, v := range a { |
| 452 |
retVal *= v |
| 453 |
} |
| 454 |
return retVal |
| 455 |
} |
| 456 |
func ProdF64(a []float64) float64 { |
| 457 |
if len(a) == 0 { |
| 458 |
return 0 |
| 459 |
} |
| 460 |
var retVal float64 = 1 |
| 461 |
a = a[:] |
| 462 |
for _, v := range a { |
| 463 |
retVal *= v |
| 464 |
} |
| 465 |
return retVal |
| 466 |
} |
| 467 |
func ProdC64(a []complex64) complex64 { |
| 468 |
if len(a) == 0 { |
| 469 |
return 0 |
| 470 |
} |
| 471 |
var retVal complex64 = 1 |
| 472 |
a = a[:] |
| 473 |
for _, v := range a { |
| 474 |
retVal *= v |
| 475 |
} |
| 476 |
return retVal |
| 477 |
} |
| 478 |
func ProdC128(a []complex128) complex128 { |
| 479 |
if len(a) == 0 { |
| 480 |
return 0 |
| 481 |
} |
| 482 |
var retVal complex128 = 1 |
| 483 |
a = a[:] |
| 484 |
for _, v := range a { |
| 485 |
retVal *= v |
| 486 |
} |
| 487 |
return retVal |
| 488 |
} |
| 489 |
|
| 490 |
func SliceMinI(a []int) int { |
| 491 |
if len(a) < 1 { |
| 492 |
panic("Max of empty slice is meaningless") |
| 493 |
} |
| 494 |
return ReduceI(MinI, a[0], a[1:]...) |
| 495 |
} |
| 496 |
|
| 497 |
func SliceMaxI(a []int) int { |
| 498 |
if len(a) < 1 { |
| 499 |
panic("Max of empty slice is meaningless") |
| 500 |
} |
| 501 |
return ReduceI(MaxI, a[0], a[1:]...) |
| 502 |
} |
| 503 |
|
| 504 |
func SliceMinI8(a []int8) int8 { |
| 505 |
if len(a) < 1 { |
| 506 |
panic("Max of empty slice is meaningless") |
| 507 |
} |
| 508 |
return ReduceI8(MinI8, a[0], a[1:]...) |
| 509 |
} |
| 510 |
|
| 511 |
func SliceMaxI8(a []int8) int8 { |
| 512 |
if len(a) < 1 { |
| 513 |
panic("Max of empty slice is meaningless") |
| 514 |
} |
| 515 |
return ReduceI8(MaxI8, a[0], a[1:]...) |
| 516 |
} |
| 517 |
|
| 518 |
func SliceMinI16(a []int16) int16 { |
| 519 |
if len(a) < 1 { |
| 520 |
panic("Max of empty slice is meaningless") |
| 521 |
} |
| 522 |
return ReduceI16(MinI16, a[0], a[1:]...) |
| 523 |
} |
| 524 |
|
| 525 |
func SliceMaxI16(a []int16) int16 { |
| 526 |
if len(a) < 1 { |
| 527 |
panic("Max of empty slice is meaningless") |
| 528 |
} |
| 529 |
return ReduceI16(MaxI16, a[0], a[1:]...) |
| 530 |
} |
| 531 |
|
| 532 |
func SliceMinI32(a []int32) int32 { |
| 533 |
if len(a) < 1 { |
| 534 |
panic("Max of empty slice is meaningless") |
| 535 |
} |
| 536 |
return ReduceI32(MinI32, a[0], a[1:]...) |
| 537 |
} |
| 538 |
|
| 539 |
func SliceMaxI32(a []int32) int32 { |
| 540 |
if len(a) < 1 { |
| 541 |
panic("Max of empty slice is meaningless") |
| 542 |
} |
| 543 |
return ReduceI32(MaxI32, a[0], a[1:]...) |
| 544 |
} |
| 545 |
|
| 546 |
func SliceMinI64(a []int64) int64 { |
| 547 |
if len(a) < 1 { |
| 548 |
panic("Max of empty slice is meaningless") |
| 549 |
} |
| 550 |
return ReduceI64(MinI64, a[0], a[1:]...) |
| 551 |
} |
| 552 |
|
| 553 |
func SliceMaxI64(a []int64) int64 { |
| 554 |
if len(a) < 1 { |
| 555 |
panic("Max of empty slice is meaningless") |
| 556 |
} |
| 557 |
return ReduceI64(MaxI64, a[0], a[1:]...) |
| 558 |
} |
| 559 |
|
| 560 |
func SliceMinU(a []uint) uint { |
| 561 |
if len(a) < 1 { |
| 562 |
panic("Max of empty slice is meaningless") |
| 563 |
} |
| 564 |
return ReduceU(MinU, a[0], a[1:]...) |
| 565 |
} |
| 566 |
|
| 567 |
func SliceMaxU(a []uint) uint { |
| 568 |
if len(a) < 1 { |
| 569 |
panic("Max of empty slice is meaningless") |
| 570 |
} |
| 571 |
return ReduceU(MaxU, a[0], a[1:]...) |
| 572 |
} |
| 573 |
|
| 574 |
func SliceMinU8(a []uint8) uint8 { |
| 575 |
if len(a) < 1 { |
| 576 |
panic("Max of empty slice is meaningless") |
| 577 |
} |
| 578 |
return ReduceU8(MinU8, a[0], a[1:]...) |
| 579 |
} |
| 580 |
|
| 581 |
func SliceMaxU8(a []uint8) uint8 { |
| 582 |
if len(a) < 1 { |
| 583 |
panic("Max of empty slice is meaningless") |
| 584 |
} |
| 585 |
return ReduceU8(MaxU8, a[0], a[1:]...) |
| 586 |
} |
| 587 |
|
| 588 |
func SliceMinU16(a []uint16) uint16 { |
| 589 |
if len(a) < 1 { |
| 590 |
panic("Max of empty slice is meaningless") |
| 591 |
} |
| 592 |
return ReduceU16(MinU16, a[0], a[1:]...) |
| 593 |
} |
| 594 |
|
| 595 |
func SliceMaxU16(a []uint16) uint16 { |
| 596 |
if len(a) < 1 { |
| 597 |
panic("Max of empty slice is meaningless") |
| 598 |
} |
| 599 |
return ReduceU16(MaxU16, a[0], a[1:]...) |
| 600 |
} |
| 601 |
|
| 602 |
func SliceMinU32(a []uint32) uint32 { |
| 603 |
if len(a) < 1 { |
| 604 |
panic("Max of empty slice is meaningless") |
| 605 |
} |
| 606 |
return ReduceU32(MinU32, a[0], a[1:]...) |
| 607 |
} |
| 608 |
|
| 609 |
func SliceMaxU32(a []uint32) uint32 { |
| 610 |
if len(a) < 1 { |
| 611 |
panic("Max of empty slice is meaningless") |
| 612 |
} |
| 613 |
return ReduceU32(MaxU32, a[0], a[1:]...) |
| 614 |
} |
| 615 |
|
| 616 |
func SliceMinU64(a []uint64) uint64 { |
| 617 |
if len(a) < 1 { |
| 618 |
panic("Max of empty slice is meaningless") |
| 619 |
} |
| 620 |
return ReduceU64(MinU64, a[0], a[1:]...) |
| 621 |
} |
| 622 |
|
| 623 |
func SliceMaxU64(a []uint64) uint64 { |
| 624 |
if len(a) < 1 { |
| 625 |
panic("Max of empty slice is meaningless") |
| 626 |
} |
| 627 |
return ReduceU64(MaxU64, a[0], a[1:]...) |
| 628 |
} |
| 629 |
|
| 630 |
func SliceMinF32(a []float32) float32 { |
| 631 |
if len(a) < 1 { |
| 632 |
panic("Max of empty slice is meaningless") |
| 633 |
} |
| 634 |
return ReduceF32(MinF32, a[0], a[1:]...) |
| 635 |
} |
| 636 |
|
| 637 |
func SliceMaxF32(a []float32) float32 { |
| 638 |
if len(a) < 1 { |
| 639 |
panic("Max of empty slice is meaningless") |
| 640 |
} |
| 641 |
return ReduceF32(MaxF32, a[0], a[1:]...) |
| 642 |
} |
| 643 |
|
| 644 |
func SliceMinF64(a []float64) float64 { |
| 645 |
if len(a) < 1 { |
| 646 |
panic("Max of empty slice is meaningless") |
| 647 |
} |
| 648 |
return ReduceF64(MinF64, a[0], a[1:]...) |
| 649 |
} |
| 650 |
|
| 651 |
func SliceMaxF64(a []float64) float64 { |
| 652 |
if len(a) < 1 { |
| 653 |
panic("Max of empty slice is meaningless") |
| 654 |
} |
| 655 |
return ReduceF64(MaxF64, a[0], a[1:]...) |
| 656 |
} |
| 657 |
|
| 658 |
func reduceFirstB(data, retVal []bool, split, size int, fn func(a, b []bool)) { |
| 659 |
start := split |
| 660 |
copy(retVal[0:split], data[0:split]) |
| 661 |
for i := 0; i < size-1; i++ { |
| 662 |
fn(retVal, data[start:start+split]) |
| 663 |
start += split |
| 664 |
} |
| 665 |
} |
| 666 |
|
| 667 |
func genericReduceFirstB(data, retVal []bool, split, size int, fn func(a, b bool) bool) { |
| 668 |
start := split |
| 669 |
copy(retVal[0:split], data[0:split]) |
| 670 |
for i := 0; i < size-1; i++ { |
| 671 |
for j := 0; j < split; j++ { |
| 672 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 673 |
} |
| 674 |
start += split |
| 675 |
} |
| 676 |
} |
| 677 |
func reduceFirstI(data, retVal []int, split, size int, fn func(a, b []int)) { |
| 678 |
start := split |
| 679 |
copy(retVal[0:split], data[0:split]) |
| 680 |
for i := 0; i < size-1; i++ { |
| 681 |
fn(retVal, data[start:start+split]) |
| 682 |
start += split |
| 683 |
} |
| 684 |
} |
| 685 |
|
| 686 |
func genericReduceFirstI(data, retVal []int, split, size int, fn func(a, b int) int) { |
| 687 |
start := split |
| 688 |
copy(retVal[0:split], data[0:split]) |
| 689 |
for i := 0; i < size-1; i++ { |
| 690 |
for j := 0; j < split; j++ { |
| 691 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 692 |
} |
| 693 |
start += split |
| 694 |
} |
| 695 |
} |
| 696 |
func reduceFirstI8(data, retVal []int8, split, size int, fn func(a, b []int8)) { |
| 697 |
start := split |
| 698 |
copy(retVal[0:split], data[0:split]) |
| 699 |
for i := 0; i < size-1; i++ { |
| 700 |
fn(retVal, data[start:start+split]) |
| 701 |
start += split |
| 702 |
} |
| 703 |
} |
| 704 |
|
| 705 |
func genericReduceFirstI8(data, retVal []int8, split, size int, fn func(a, b int8) int8) { |
| 706 |
start := split |
| 707 |
copy(retVal[0:split], data[0:split]) |
| 708 |
for i := 0; i < size-1; i++ { |
| 709 |
for j := 0; j < split; j++ { |
| 710 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 711 |
} |
| 712 |
start += split |
| 713 |
} |
| 714 |
} |
| 715 |
func reduceFirstI16(data, retVal []int16, split, size int, fn func(a, b []int16)) { |
| 716 |
start := split |
| 717 |
copy(retVal[0:split], data[0:split]) |
| 718 |
for i := 0; i < size-1; i++ { |
| 719 |
fn(retVal, data[start:start+split]) |
| 720 |
start += split |
| 721 |
} |
| 722 |
} |
| 723 |
|
| 724 |
func genericReduceFirstI16(data, retVal []int16, split, size int, fn func(a, b int16) int16) { |
| 725 |
start := split |
| 726 |
copy(retVal[0:split], data[0:split]) |
| 727 |
for i := 0; i < size-1; i++ { |
| 728 |
for j := 0; j < split; j++ { |
| 729 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 730 |
} |
| 731 |
start += split |
| 732 |
} |
| 733 |
} |
| 734 |
func reduceFirstI32(data, retVal []int32, split, size int, fn func(a, b []int32)) { |
| 735 |
start := split |
| 736 |
copy(retVal[0:split], data[0:split]) |
| 737 |
for i := 0; i < size-1; i++ { |
| 738 |
fn(retVal, data[start:start+split]) |
| 739 |
start += split |
| 740 |
} |
| 741 |
} |
| 742 |
|
| 743 |
func genericReduceFirstI32(data, retVal []int32, split, size int, fn func(a, b int32) int32) { |
| 744 |
start := split |
| 745 |
copy(retVal[0:split], data[0:split]) |
| 746 |
for i := 0; i < size-1; i++ { |
| 747 |
for j := 0; j < split; j++ { |
| 748 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 749 |
} |
| 750 |
start += split |
| 751 |
} |
| 752 |
} |
| 753 |
func reduceFirstI64(data, retVal []int64, split, size int, fn func(a, b []int64)) { |
| 754 |
start := split |
| 755 |
copy(retVal[0:split], data[0:split]) |
| 756 |
for i := 0; i < size-1; i++ { |
| 757 |
fn(retVal, data[start:start+split]) |
| 758 |
start += split |
| 759 |
} |
| 760 |
} |
| 761 |
|
| 762 |
func genericReduceFirstI64(data, retVal []int64, split, size int, fn func(a, b int64) int64) { |
| 763 |
start := split |
| 764 |
copy(retVal[0:split], data[0:split]) |
| 765 |
for i := 0; i < size-1; i++ { |
| 766 |
for j := 0; j < split; j++ { |
| 767 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 768 |
} |
| 769 |
start += split |
| 770 |
} |
| 771 |
} |
| 772 |
func reduceFirstU(data, retVal []uint, split, size int, fn func(a, b []uint)) { |
| 773 |
start := split |
| 774 |
copy(retVal[0:split], data[0:split]) |
| 775 |
for i := 0; i < size-1; i++ { |
| 776 |
fn(retVal, data[start:start+split]) |
| 777 |
start += split |
| 778 |
} |
| 779 |
} |
| 780 |
|
| 781 |
func genericReduceFirstU(data, retVal []uint, split, size int, fn func(a, b uint) uint) { |
| 782 |
start := split |
| 783 |
copy(retVal[0:split], data[0:split]) |
| 784 |
for i := 0; i < size-1; i++ { |
| 785 |
for j := 0; j < split; j++ { |
| 786 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 787 |
} |
| 788 |
start += split |
| 789 |
} |
| 790 |
} |
| 791 |
func reduceFirstU8(data, retVal []uint8, split, size int, fn func(a, b []uint8)) { |
| 792 |
start := split |
| 793 |
copy(retVal[0:split], data[0:split]) |
| 794 |
for i := 0; i < size-1; i++ { |
| 795 |
fn(retVal, data[start:start+split]) |
| 796 |
start += split |
| 797 |
} |
| 798 |
} |
| 799 |
|
| 800 |
func genericReduceFirstU8(data, retVal []uint8, split, size int, fn func(a, b uint8) uint8) { |
| 801 |
start := split |
| 802 |
copy(retVal[0:split], data[0:split]) |
| 803 |
for i := 0; i < size-1; i++ { |
| 804 |
for j := 0; j < split; j++ { |
| 805 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 806 |
} |
| 807 |
start += split |
| 808 |
} |
| 809 |
} |
| 810 |
func reduceFirstU16(data, retVal []uint16, split, size int, fn func(a, b []uint16)) { |
| 811 |
start := split |
| 812 |
copy(retVal[0:split], data[0:split]) |
| 813 |
for i := 0; i < size-1; i++ { |
| 814 |
fn(retVal, data[start:start+split]) |
| 815 |
start += split |
| 816 |
} |
| 817 |
} |
| 818 |
|
| 819 |
func genericReduceFirstU16(data, retVal []uint16, split, size int, fn func(a, b uint16) uint16) { |
| 820 |
start := split |
| 821 |
copy(retVal[0:split], data[0:split]) |
| 822 |
for i := 0; i < size-1; i++ { |
| 823 |
for j := 0; j < split; j++ { |
| 824 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 825 |
} |
| 826 |
start += split |
| 827 |
} |
| 828 |
} |
| 829 |
func reduceFirstU32(data, retVal []uint32, split, size int, fn func(a, b []uint32)) { |
| 830 |
start := split |
| 831 |
copy(retVal[0:split], data[0:split]) |
| 832 |
for i := 0; i < size-1; i++ { |
| 833 |
fn(retVal, data[start:start+split]) |
| 834 |
start += split |
| 835 |
} |
| 836 |
} |
| 837 |
|
| 838 |
func genericReduceFirstU32(data, retVal []uint32, split, size int, fn func(a, b uint32) uint32) { |
| 839 |
start := split |
| 840 |
copy(retVal[0:split], data[0:split]) |
| 841 |
for i := 0; i < size-1; i++ { |
| 842 |
for j := 0; j < split; j++ { |
| 843 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 844 |
} |
| 845 |
start += split |
| 846 |
} |
| 847 |
} |
| 848 |
func reduceFirstU64(data, retVal []uint64, split, size int, fn func(a, b []uint64)) { |
| 849 |
start := split |
| 850 |
copy(retVal[0:split], data[0:split]) |
| 851 |
for i := 0; i < size-1; i++ { |
| 852 |
fn(retVal, data[start:start+split]) |
| 853 |
start += split |
| 854 |
} |
| 855 |
} |
| 856 |
|
| 857 |
func genericReduceFirstU64(data, retVal []uint64, split, size int, fn func(a, b uint64) uint64) { |
| 858 |
start := split |
| 859 |
copy(retVal[0:split], data[0:split]) |
| 860 |
for i := 0; i < size-1; i++ { |
| 861 |
for j := 0; j < split; j++ { |
| 862 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 863 |
} |
| 864 |
start += split |
| 865 |
} |
| 866 |
} |
| 867 |
func reduceFirstUintptr(data, retVal []uintptr, split, size int, fn func(a, b []uintptr)) { |
| 868 |
start := split |
| 869 |
copy(retVal[0:split], data[0:split]) |
| 870 |
for i := 0; i < size-1; i++ { |
| 871 |
fn(retVal, data[start:start+split]) |
| 872 |
start += split |
| 873 |
} |
| 874 |
} |
| 875 |
|
| 876 |
func genericReduceFirstUintptr(data, retVal []uintptr, split, size int, fn func(a, b uintptr) uintptr) { |
| 877 |
start := split |
| 878 |
copy(retVal[0:split], data[0:split]) |
| 879 |
for i := 0; i < size-1; i++ { |
| 880 |
for j := 0; j < split; j++ { |
| 881 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 882 |
} |
| 883 |
start += split |
| 884 |
} |
| 885 |
} |
| 886 |
func reduceFirstF32(data, retVal []float32, split, size int, fn func(a, b []float32)) { |
| 887 |
start := split |
| 888 |
copy(retVal[0:split], data[0:split]) |
| 889 |
for i := 0; i < size-1; i++ { |
| 890 |
fn(retVal, data[start:start+split]) |
| 891 |
start += split |
| 892 |
} |
| 893 |
} |
| 894 |
|
| 895 |
func genericReduceFirstF32(data, retVal []float32, split, size int, fn func(a, b float32) float32) { |
| 896 |
start := split |
| 897 |
copy(retVal[0:split], data[0:split]) |
| 898 |
for i := 0; i < size-1; i++ { |
| 899 |
for j := 0; j < split; j++ { |
| 900 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 901 |
} |
| 902 |
start += split |
| 903 |
} |
| 904 |
} |
| 905 |
func reduceFirstF64(data, retVal []float64, split, size int, fn func(a, b []float64)) { |
| 906 |
start := split |
| 907 |
copy(retVal[0:split], data[0:split]) |
| 908 |
for i := 0; i < size-1; i++ { |
| 909 |
fn(retVal, data[start:start+split]) |
| 910 |
start += split |
| 911 |
} |
| 912 |
} |
| 913 |
|
| 914 |
func genericReduceFirstF64(data, retVal []float64, split, size int, fn func(a, b float64) float64) { |
| 915 |
start := split |
| 916 |
copy(retVal[0:split], data[0:split]) |
| 917 |
for i := 0; i < size-1; i++ { |
| 918 |
for j := 0; j < split; j++ { |
| 919 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 920 |
} |
| 921 |
start += split |
| 922 |
} |
| 923 |
} |
| 924 |
func reduceFirstC64(data, retVal []complex64, split, size int, fn func(a, b []complex64)) { |
| 925 |
start := split |
| 926 |
copy(retVal[0:split], data[0:split]) |
| 927 |
for i := 0; i < size-1; i++ { |
| 928 |
fn(retVal, data[start:start+split]) |
| 929 |
start += split |
| 930 |
} |
| 931 |
} |
| 932 |
|
| 933 |
func genericReduceFirstC64(data, retVal []complex64, split, size int, fn func(a, b complex64) complex64) { |
| 934 |
start := split |
| 935 |
copy(retVal[0:split], data[0:split]) |
| 936 |
for i := 0; i < size-1; i++ { |
| 937 |
for j := 0; j < split; j++ { |
| 938 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 939 |
} |
| 940 |
start += split |
| 941 |
} |
| 942 |
} |
| 943 |
func reduceFirstC128(data, retVal []complex128, split, size int, fn func(a, b []complex128)) { |
| 944 |
start := split |
| 945 |
copy(retVal[0:split], data[0:split]) |
| 946 |
for i := 0; i < size-1; i++ { |
| 947 |
fn(retVal, data[start:start+split]) |
| 948 |
start += split |
| 949 |
} |
| 950 |
} |
| 951 |
|
| 952 |
func genericReduceFirstC128(data, retVal []complex128, split, size int, fn func(a, b complex128) complex128) { |
| 953 |
start := split |
| 954 |
copy(retVal[0:split], data[0:split]) |
| 955 |
for i := 0; i < size-1; i++ { |
| 956 |
for j := 0; j < split; j++ { |
| 957 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 958 |
} |
| 959 |
start += split |
| 960 |
} |
| 961 |
} |
| 962 |
func reduceFirstStr(data, retVal []string, split, size int, fn func(a, b []string)) { |
| 963 |
start := split |
| 964 |
copy(retVal[0:split], data[0:split]) |
| 965 |
for i := 0; i < size-1; i++ { |
| 966 |
fn(retVal, data[start:start+split]) |
| 967 |
start += split |
| 968 |
} |
| 969 |
} |
| 970 |
|
| 971 |
func genericReduceFirstStr(data, retVal []string, split, size int, fn func(a, b string) string) { |
| 972 |
start := split |
| 973 |
copy(retVal[0:split], data[0:split]) |
| 974 |
for i := 0; i < size-1; i++ { |
| 975 |
for j := 0; j < split; j++ { |
| 976 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 977 |
} |
| 978 |
start += split |
| 979 |
} |
| 980 |
} |
| 981 |
func reduceFirstUnsafePointer(data, retVal []unsafe.Pointer, split, size int, fn func(a, b []unsafe.Pointer)) { |
| 982 |
start := split |
| 983 |
copy(retVal[0:split], data[0:split]) |
| 984 |
for i := 0; i < size-1; i++ { |
| 985 |
fn(retVal, data[start:start+split]) |
| 986 |
start += split |
| 987 |
} |
| 988 |
} |
| 989 |
|
| 990 |
func genericReduceFirstUnsafePointer(data, retVal []unsafe.Pointer, split, size int, fn func(a, b unsafe.Pointer) unsafe.Pointer) { |
| 991 |
start := split |
| 992 |
copy(retVal[0:split], data[0:split]) |
| 993 |
for i := 0; i < size-1; i++ { |
| 994 |
for j := 0; j < split; j++ { |
| 995 |
retVal[j] = fn(retVal[j], data[j+start]) |
| 996 |
} |
| 997 |
start += split |
| 998 |
} |
| 999 |
} |
| 1000 |
func reduceLastB(a, retVal []bool, dimSize int, defaultValue bool, fn func(a []bool) bool) { |
| 1001 |
var at int |
| 1002 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1003 |
r := fn(a[start : start+dimSize]) |
| 1004 |
retVal[at] = r |
| 1005 |
at++ |
| 1006 |
} |
| 1007 |
} |
| 1008 |
|
| 1009 |
func genericReduceLastB(a, retVal []bool, dimSize int, defaultValue bool, fn func(bool, bool) bool) { |
| 1010 |
var at int |
| 1011 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1012 |
r := ReduceB(fn, defaultValue, a[start:start+dimSize]...) |
| 1013 |
retVal[at] = r |
| 1014 |
at++ |
| 1015 |
} |
| 1016 |
} |
| 1017 |
|
| 1018 |
func reduceLastI(a, retVal []int, dimSize int, defaultValue int, fn func(a []int) int) { |
| 1019 |
var at int |
| 1020 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1021 |
r := fn(a[start : start+dimSize]) |
| 1022 |
retVal[at] = r |
| 1023 |
at++ |
| 1024 |
} |
| 1025 |
} |
| 1026 |
|
| 1027 |
func genericReduceLastI(a, retVal []int, dimSize int, defaultValue int, fn func(int, int) int) { |
| 1028 |
var at int |
| 1029 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1030 |
r := ReduceI(fn, defaultValue, a[start:start+dimSize]...) |
| 1031 |
retVal[at] = r |
| 1032 |
at++ |
| 1033 |
} |
| 1034 |
} |
| 1035 |
|
| 1036 |
func reduceLastI8(a, retVal []int8, dimSize int, defaultValue int8, fn func(a []int8) int8) { |
| 1037 |
var at int |
| 1038 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1039 |
r := fn(a[start : start+dimSize]) |
| 1040 |
retVal[at] = r |
| 1041 |
at++ |
| 1042 |
} |
| 1043 |
} |
| 1044 |
|
| 1045 |
func genericReduceLastI8(a, retVal []int8, dimSize int, defaultValue int8, fn func(int8, int8) int8) { |
| 1046 |
var at int |
| 1047 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1048 |
r := ReduceI8(fn, defaultValue, a[start:start+dimSize]...) |
| 1049 |
retVal[at] = r |
| 1050 |
at++ |
| 1051 |
} |
| 1052 |
} |
| 1053 |
|
| 1054 |
func reduceLastI16(a, retVal []int16, dimSize int, defaultValue int16, fn func(a []int16) int16) { |
| 1055 |
var at int |
| 1056 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1057 |
r := fn(a[start : start+dimSize]) |
| 1058 |
retVal[at] = r |
| 1059 |
at++ |
| 1060 |
} |
| 1061 |
} |
| 1062 |
|
| 1063 |
func genericReduceLastI16(a, retVal []int16, dimSize int, defaultValue int16, fn func(int16, int16) int16) { |
| 1064 |
var at int |
| 1065 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1066 |
r := ReduceI16(fn, defaultValue, a[start:start+dimSize]...) |
| 1067 |
retVal[at] = r |
| 1068 |
at++ |
| 1069 |
} |
| 1070 |
} |
| 1071 |
|
| 1072 |
func reduceLastI32(a, retVal []int32, dimSize int, defaultValue int32, fn func(a []int32) int32) { |
| 1073 |
var at int |
| 1074 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1075 |
r := fn(a[start : start+dimSize]) |
| 1076 |
retVal[at] = r |
| 1077 |
at++ |
| 1078 |
} |
| 1079 |
} |
| 1080 |
|
| 1081 |
func genericReduceLastI32(a, retVal []int32, dimSize int, defaultValue int32, fn func(int32, int32) int32) { |
| 1082 |
var at int |
| 1083 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1084 |
r := ReduceI32(fn, defaultValue, a[start:start+dimSize]...) |
| 1085 |
retVal[at] = r |
| 1086 |
at++ |
| 1087 |
} |
| 1088 |
} |
| 1089 |
|
| 1090 |
func reduceLastI64(a, retVal []int64, dimSize int, defaultValue int64, fn func(a []int64) int64) { |
| 1091 |
var at int |
| 1092 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1093 |
r := fn(a[start : start+dimSize]) |
| 1094 |
retVal[at] = r |
| 1095 |
at++ |
| 1096 |
} |
| 1097 |
} |
| 1098 |
|
| 1099 |
func genericReduceLastI64(a, retVal []int64, dimSize int, defaultValue int64, fn func(int64, int64) int64) { |
| 1100 |
var at int |
| 1101 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1102 |
r := ReduceI64(fn, defaultValue, a[start:start+dimSize]...) |
| 1103 |
retVal[at] = r |
| 1104 |
at++ |
| 1105 |
} |
| 1106 |
} |
| 1107 |
|
| 1108 |
func reduceLastU(a, retVal []uint, dimSize int, defaultValue uint, fn func(a []uint) uint) { |
| 1109 |
var at int |
| 1110 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1111 |
r := fn(a[start : start+dimSize]) |
| 1112 |
retVal[at] = r |
| 1113 |
at++ |
| 1114 |
} |
| 1115 |
} |
| 1116 |
|
| 1117 |
func genericReduceLastU(a, retVal []uint, dimSize int, defaultValue uint, fn func(uint, uint) uint) { |
| 1118 |
var at int |
| 1119 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1120 |
r := ReduceU(fn, defaultValue, a[start:start+dimSize]...) |
| 1121 |
retVal[at] = r |
| 1122 |
at++ |
| 1123 |
} |
| 1124 |
} |
| 1125 |
|
| 1126 |
func reduceLastU8(a, retVal []uint8, dimSize int, defaultValue uint8, fn func(a []uint8) uint8) { |
| 1127 |
var at int |
| 1128 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1129 |
r := fn(a[start : start+dimSize]) |
| 1130 |
retVal[at] = r |
| 1131 |
at++ |
| 1132 |
} |
| 1133 |
} |
| 1134 |
|
| 1135 |
func genericReduceLastU8(a, retVal []uint8, dimSize int, defaultValue uint8, fn func(uint8, uint8) uint8) { |
| 1136 |
var at int |
| 1137 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1138 |
r := ReduceU8(fn, defaultValue, a[start:start+dimSize]...) |
| 1139 |
retVal[at] = r |
| 1140 |
at++ |
| 1141 |
} |
| 1142 |
} |
| 1143 |
|
| 1144 |
func reduceLastU16(a, retVal []uint16, dimSize int, defaultValue uint16, fn func(a []uint16) uint16) { |
| 1145 |
var at int |
| 1146 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1147 |
r := fn(a[start : start+dimSize]) |
| 1148 |
retVal[at] = r |
| 1149 |
at++ |
| 1150 |
} |
| 1151 |
} |
| 1152 |
|
| 1153 |
func genericReduceLastU16(a, retVal []uint16, dimSize int, defaultValue uint16, fn func(uint16, uint16) uint16) { |
| 1154 |
var at int |
| 1155 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1156 |
r := ReduceU16(fn, defaultValue, a[start:start+dimSize]...) |
| 1157 |
retVal[at] = r |
| 1158 |
at++ |
| 1159 |
} |
| 1160 |
} |
| 1161 |
|
| 1162 |
func reduceLastU32(a, retVal []uint32, dimSize int, defaultValue uint32, fn func(a []uint32) uint32) { |
| 1163 |
var at int |
| 1164 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1165 |
r := fn(a[start : start+dimSize]) |
| 1166 |
retVal[at] = r |
| 1167 |
at++ |
| 1168 |
} |
| 1169 |
} |
| 1170 |
|
| 1171 |
func genericReduceLastU32(a, retVal []uint32, dimSize int, defaultValue uint32, fn func(uint32, uint32) uint32) { |
| 1172 |
var at int |
| 1173 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1174 |
r := ReduceU32(fn, defaultValue, a[start:start+dimSize]...) |
| 1175 |
retVal[at] = r |
| 1176 |
at++ |
| 1177 |
} |
| 1178 |
} |
| 1179 |
|
| 1180 |
func reduceLastU64(a, retVal []uint64, dimSize int, defaultValue uint64, fn func(a []uint64) uint64) { |
| 1181 |
var at int |
| 1182 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1183 |
r := fn(a[start : start+dimSize]) |
| 1184 |
retVal[at] = r |
| 1185 |
at++ |
| 1186 |
} |
| 1187 |
} |
| 1188 |
|
| 1189 |
func genericReduceLastU64(a, retVal []uint64, dimSize int, defaultValue uint64, fn func(uint64, uint64) uint64) { |
| 1190 |
var at int |
| 1191 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1192 |
r := ReduceU64(fn, defaultValue, a[start:start+dimSize]...) |
| 1193 |
retVal[at] = r |
| 1194 |
at++ |
| 1195 |
} |
| 1196 |
} |
| 1197 |
|
| 1198 |
func reduceLastUintptr(a, retVal []uintptr, dimSize int, defaultValue uintptr, fn func(a []uintptr) uintptr) { |
| 1199 |
var at int |
| 1200 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1201 |
r := fn(a[start : start+dimSize]) |
| 1202 |
retVal[at] = r |
| 1203 |
at++ |
| 1204 |
} |
| 1205 |
} |
| 1206 |
|
| 1207 |
func genericReduceLastUintptr(a, retVal []uintptr, dimSize int, defaultValue uintptr, fn func(uintptr, uintptr) uintptr) { |
| 1208 |
var at int |
| 1209 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1210 |
r := ReduceUintptr(fn, defaultValue, a[start:start+dimSize]...) |
| 1211 |
retVal[at] = r |
| 1212 |
at++ |
| 1213 |
} |
| 1214 |
} |
| 1215 |
|
| 1216 |
func reduceLastF32(a, retVal []float32, dimSize int, defaultValue float32, fn func(a []float32) float32) { |
| 1217 |
var at int |
| 1218 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1219 |
r := fn(a[start : start+dimSize]) |
| 1220 |
retVal[at] = r |
| 1221 |
at++ |
| 1222 |
} |
| 1223 |
} |
| 1224 |
|
| 1225 |
func genericReduceLastF32(a, retVal []float32, dimSize int, defaultValue float32, fn func(float32, float32) float32) { |
| 1226 |
var at int |
| 1227 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1228 |
r := ReduceF32(fn, defaultValue, a[start:start+dimSize]...) |
| 1229 |
retVal[at] = r |
| 1230 |
at++ |
| 1231 |
} |
| 1232 |
} |
| 1233 |
|
| 1234 |
func reduceLastF64(a, retVal []float64, dimSize int, defaultValue float64, fn func(a []float64) float64) { |
| 1235 |
var at int |
| 1236 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1237 |
r := fn(a[start : start+dimSize]) |
| 1238 |
retVal[at] = r |
| 1239 |
at++ |
| 1240 |
} |
| 1241 |
} |
| 1242 |
|
| 1243 |
func genericReduceLastF64(a, retVal []float64, dimSize int, defaultValue float64, fn func(float64, float64) float64) { |
| 1244 |
var at int |
| 1245 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1246 |
r := ReduceF64(fn, defaultValue, a[start:start+dimSize]...) |
| 1247 |
retVal[at] = r |
| 1248 |
at++ |
| 1249 |
} |
| 1250 |
} |
| 1251 |
|
| 1252 |
func reduceLastC64(a, retVal []complex64, dimSize int, defaultValue complex64, fn func(a []complex64) complex64) { |
| 1253 |
var at int |
| 1254 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1255 |
r := fn(a[start : start+dimSize]) |
| 1256 |
retVal[at] = r |
| 1257 |
at++ |
| 1258 |
} |
| 1259 |
} |
| 1260 |
|
| 1261 |
func genericReduceLastC64(a, retVal []complex64, dimSize int, defaultValue complex64, fn func(complex64, complex64) complex64) { |
| 1262 |
var at int |
| 1263 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1264 |
r := ReduceC64(fn, defaultValue, a[start:start+dimSize]...) |
| 1265 |
retVal[at] = r |
| 1266 |
at++ |
| 1267 |
} |
| 1268 |
} |
| 1269 |
|
| 1270 |
func reduceLastC128(a, retVal []complex128, dimSize int, defaultValue complex128, fn func(a []complex128) complex128) { |
| 1271 |
var at int |
| 1272 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1273 |
r := fn(a[start : start+dimSize]) |
| 1274 |
retVal[at] = r |
| 1275 |
at++ |
| 1276 |
} |
| 1277 |
} |
| 1278 |
|
| 1279 |
func genericReduceLastC128(a, retVal []complex128, dimSize int, defaultValue complex128, fn func(complex128, complex128) complex128) { |
| 1280 |
var at int |
| 1281 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1282 |
r := ReduceC128(fn, defaultValue, a[start:start+dimSize]...) |
| 1283 |
retVal[at] = r |
| 1284 |
at++ |
| 1285 |
} |
| 1286 |
} |
| 1287 |
|
| 1288 |
func reduceLastStr(a, retVal []string, dimSize int, defaultValue string, fn func(a []string) string) { |
| 1289 |
var at int |
| 1290 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1291 |
r := fn(a[start : start+dimSize]) |
| 1292 |
retVal[at] = r |
| 1293 |
at++ |
| 1294 |
} |
| 1295 |
} |
| 1296 |
|
| 1297 |
func genericReduceLastStr(a, retVal []string, dimSize int, defaultValue string, fn func(string, string) string) { |
| 1298 |
var at int |
| 1299 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1300 |
r := ReduceStr(fn, defaultValue, a[start:start+dimSize]...) |
| 1301 |
retVal[at] = r |
| 1302 |
at++ |
| 1303 |
} |
| 1304 |
} |
| 1305 |
|
| 1306 |
func reduceLastUnsafePointer(a, retVal []unsafe.Pointer, dimSize int, defaultValue unsafe.Pointer, fn func(a []unsafe.Pointer) unsafe.Pointer) { |
| 1307 |
var at int |
| 1308 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1309 |
r := fn(a[start : start+dimSize]) |
| 1310 |
retVal[at] = r |
| 1311 |
at++ |
| 1312 |
} |
| 1313 |
} |
| 1314 |
|
| 1315 |
func genericReduceLastUnsafePointer(a, retVal []unsafe.Pointer, dimSize int, defaultValue unsafe.Pointer, fn func(unsafe.Pointer, unsafe.Pointer) unsafe.Pointer) { |
| 1316 |
var at int |
| 1317 |
for start := 0; start <= len(a)-dimSize; start += dimSize { |
| 1318 |
r := ReduceUnsafePointer(fn, defaultValue, a[start:start+dimSize]...) |
| 1319 |
retVal[at] = r |
| 1320 |
at++ |
| 1321 |
} |
| 1322 |
} |
| 1323 |
|
| 1324 |
func reduceDefaultB(data, retVal []bool, dim0, dimSize, outerStride, stride, expected int, fn func(a, b bool) bool) { |
| 1325 |
for i := 0; i < dim0; i++ { |
| 1326 |
start := i * outerStride |
| 1327 |
sliced := data[start : start+outerStride] |
| 1328 |
var innerStart, strideTrack int |
| 1329 |
for j := 0; j < expected; j++ { |
| 1330 |
writeTo := i*expected + j |
| 1331 |
retVal[writeTo] = sliced[innerStart] |
| 1332 |
for k := 1; k < dimSize; k++ { |
| 1333 |
readFrom := innerStart + k*stride |
| 1334 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1335 |
} |
| 1336 |
strideTrack++ |
| 1337 |
if strideTrack >= stride { |
| 1338 |
strideTrack = 0 |
| 1339 |
innerStart += stride |
| 1340 |
} |
| 1341 |
innerStart++ |
| 1342 |
} |
| 1343 |
} |
| 1344 |
} |
| 1345 |
|
| 1346 |
func reduceDefaultI(data, retVal []int, dim0, dimSize, outerStride, stride, expected int, fn func(a, b int) int) { |
| 1347 |
for i := 0; i < dim0; i++ { |
| 1348 |
start := i * outerStride |
| 1349 |
sliced := data[start : start+outerStride] |
| 1350 |
var innerStart, strideTrack int |
| 1351 |
for j := 0; j < expected; j++ { |
| 1352 |
writeTo := i*expected + j |
| 1353 |
retVal[writeTo] = sliced[innerStart] |
| 1354 |
for k := 1; k < dimSize; k++ { |
| 1355 |
readFrom := innerStart + k*stride |
| 1356 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1357 |
} |
| 1358 |
strideTrack++ |
| 1359 |
if strideTrack >= stride { |
| 1360 |
strideTrack = 0 |
| 1361 |
innerStart += stride |
| 1362 |
} |
| 1363 |
innerStart++ |
| 1364 |
} |
| 1365 |
} |
| 1366 |
} |
| 1367 |
|
| 1368 |
func reduceDefaultI8(data, retVal []int8, dim0, dimSize, outerStride, stride, expected int, fn func(a, b int8) int8) { |
| 1369 |
for i := 0; i < dim0; i++ { |
| 1370 |
start := i * outerStride |
| 1371 |
sliced := data[start : start+outerStride] |
| 1372 |
var innerStart, strideTrack int |
| 1373 |
for j := 0; j < expected; j++ { |
| 1374 |
writeTo := i*expected + j |
| 1375 |
retVal[writeTo] = sliced[innerStart] |
| 1376 |
for k := 1; k < dimSize; k++ { |
| 1377 |
readFrom := innerStart + k*stride |
| 1378 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1379 |
} |
| 1380 |
strideTrack++ |
| 1381 |
if strideTrack >= stride { |
| 1382 |
strideTrack = 0 |
| 1383 |
innerStart += stride |
| 1384 |
} |
| 1385 |
innerStart++ |
| 1386 |
} |
| 1387 |
} |
| 1388 |
} |
| 1389 |
|
| 1390 |
func reduceDefaultI16(data, retVal []int16, dim0, dimSize, outerStride, stride, expected int, fn func(a, b int16) int16) { |
| 1391 |
for i := 0; i < dim0; i++ { |
| 1392 |
start := i * outerStride |
| 1393 |
sliced := data[start : start+outerStride] |
| 1394 |
var innerStart, strideTrack int |
| 1395 |
for j := 0; j < expected; j++ { |
| 1396 |
writeTo := i*expected + j |
| 1397 |
retVal[writeTo] = sliced[innerStart] |
| 1398 |
for k := 1; k < dimSize; k++ { |
| 1399 |
readFrom := innerStart + k*stride |
| 1400 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1401 |
} |
| 1402 |
strideTrack++ |
| 1403 |
if strideTrack >= stride { |
| 1404 |
strideTrack = 0 |
| 1405 |
innerStart += stride |
| 1406 |
} |
| 1407 |
innerStart++ |
| 1408 |
} |
| 1409 |
} |
| 1410 |
} |
| 1411 |
|
| 1412 |
func reduceDefaultI32(data, retVal []int32, dim0, dimSize, outerStride, stride, expected int, fn func(a, b int32) int32) { |
| 1413 |
for i := 0; i < dim0; i++ { |
| 1414 |
start := i * outerStride |
| 1415 |
sliced := data[start : start+outerStride] |
| 1416 |
var innerStart, strideTrack int |
| 1417 |
for j := 0; j < expected; j++ { |
| 1418 |
writeTo := i*expected + j |
| 1419 |
retVal[writeTo] = sliced[innerStart] |
| 1420 |
for k := 1; k < dimSize; k++ { |
| 1421 |
readFrom := innerStart + k*stride |
| 1422 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1423 |
} |
| 1424 |
strideTrack++ |
| 1425 |
if strideTrack >= stride { |
| 1426 |
strideTrack = 0 |
| 1427 |
innerStart += stride |
| 1428 |
} |
| 1429 |
innerStart++ |
| 1430 |
} |
| 1431 |
} |
| 1432 |
} |
| 1433 |
|
| 1434 |
func reduceDefaultI64(data, retVal []int64, dim0, dimSize, outerStride, stride, expected int, fn func(a, b int64) int64) { |
| 1435 |
for i := 0; i < dim0; i++ { |
| 1436 |
start := i * outerStride |
| 1437 |
sliced := data[start : start+outerStride] |
| 1438 |
var innerStart, strideTrack int |
| 1439 |
for j := 0; j < expected; j++ { |
| 1440 |
writeTo := i*expected + j |
| 1441 |
retVal[writeTo] = sliced[innerStart] |
| 1442 |
for k := 1; k < dimSize; k++ { |
| 1443 |
readFrom := innerStart + k*stride |
| 1444 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1445 |
} |
| 1446 |
strideTrack++ |
| 1447 |
if strideTrack >= stride { |
| 1448 |
strideTrack = 0 |
| 1449 |
innerStart += stride |
| 1450 |
} |
| 1451 |
innerStart++ |
| 1452 |
} |
| 1453 |
} |
| 1454 |
} |
| 1455 |
|
| 1456 |
func reduceDefaultU(data, retVal []uint, dim0, dimSize, outerStride, stride, expected int, fn func(a, b uint) uint) { |
| 1457 |
for i := 0; i < dim0; i++ { |
| 1458 |
start := i * outerStride |
| 1459 |
sliced := data[start : start+outerStride] |
| 1460 |
var innerStart, strideTrack int |
| 1461 |
for j := 0; j < expected; j++ { |
| 1462 |
writeTo := i*expected + j |
| 1463 |
retVal[writeTo] = sliced[innerStart] |
| 1464 |
for k := 1; k < dimSize; k++ { |
| 1465 |
readFrom := innerStart + k*stride |
| 1466 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1467 |
} |
| 1468 |
strideTrack++ |
| 1469 |
if strideTrack >= stride { |
| 1470 |
strideTrack = 0 |
| 1471 |
innerStart += stride |
| 1472 |
} |
| 1473 |
innerStart++ |
| 1474 |
} |
| 1475 |
} |
| 1476 |
} |
| 1477 |
|
| 1478 |
func reduceDefaultU8(data, retVal []uint8, dim0, dimSize, outerStride, stride, expected int, fn func(a, b uint8) uint8) { |
| 1479 |
for i := 0; i < dim0; i++ { |
| 1480 |
start := i * outerStride |
| 1481 |
sliced := data[start : start+outerStride] |
| 1482 |
var innerStart, strideTrack int |
| 1483 |
for j := 0; j < expected; j++ { |
| 1484 |
writeTo := i*expected + j |
| 1485 |
retVal[writeTo] = sliced[innerStart] |
| 1486 |
for k := 1; k < dimSize; k++ { |
| 1487 |
readFrom := innerStart + k*stride |
| 1488 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1489 |
} |
| 1490 |
strideTrack++ |
| 1491 |
if strideTrack >= stride { |
| 1492 |
strideTrack = 0 |
| 1493 |
innerStart += stride |
| 1494 |
} |
| 1495 |
innerStart++ |
| 1496 |
} |
| 1497 |
} |
| 1498 |
} |
| 1499 |
|
| 1500 |
func reduceDefaultU16(data, retVal []uint16, dim0, dimSize, outerStride, stride, expected int, fn func(a, b uint16) uint16) { |
| 1501 |
for i := 0; i < dim0; i++ { |
| 1502 |
start := i * outerStride |
| 1503 |
sliced := data[start : start+outerStride] |
| 1504 |
var innerStart, strideTrack int |
| 1505 |
for j := 0; j < expected; j++ { |
| 1506 |
writeTo := i*expected + j |
| 1507 |
retVal[writeTo] = sliced[innerStart] |
| 1508 |
for k := 1; k < dimSize; k++ { |
| 1509 |
readFrom := innerStart + k*stride |
| 1510 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1511 |
} |
| 1512 |
strideTrack++ |
| 1513 |
if strideTrack >= stride { |
| 1514 |
strideTrack = 0 |
| 1515 |
innerStart += stride |
| 1516 |
} |
| 1517 |
innerStart++ |
| 1518 |
} |
| 1519 |
} |
| 1520 |
} |
| 1521 |
|
| 1522 |
func reduceDefaultU32(data, retVal []uint32, dim0, dimSize, outerStride, stride, expected int, fn func(a, b uint32) uint32) { |
| 1523 |
for i := 0; i < dim0; i++ { |
| 1524 |
start := i * outerStride |
| 1525 |
sliced := data[start : start+outerStride] |
| 1526 |
var innerStart, strideTrack int |
| 1527 |
for j := 0; j < expected; j++ { |
| 1528 |
writeTo := i*expected + j |
| 1529 |
retVal[writeTo] = sliced[innerStart] |
| 1530 |
for k := 1; k < dimSize; k++ { |
| 1531 |
readFrom := innerStart + k*stride |
| 1532 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1533 |
} |
| 1534 |
strideTrack++ |
| 1535 |
if strideTrack >= stride { |
| 1536 |
strideTrack = 0 |
| 1537 |
innerStart += stride |
| 1538 |
} |
| 1539 |
innerStart++ |
| 1540 |
} |
| 1541 |
} |
| 1542 |
} |
| 1543 |
|
| 1544 |
func reduceDefaultU64(data, retVal []uint64, dim0, dimSize, outerStride, stride, expected int, fn func(a, b uint64) uint64) { |
| 1545 |
for i := 0; i < dim0; i++ { |
| 1546 |
start := i * outerStride |
| 1547 |
sliced := data[start : start+outerStride] |
| 1548 |
var innerStart, strideTrack int |
| 1549 |
for j := 0; j < expected; j++ { |
| 1550 |
writeTo := i*expected + j |
| 1551 |
retVal[writeTo] = sliced[innerStart] |
| 1552 |
for k := 1; k < dimSize; k++ { |
| 1553 |
readFrom := innerStart + k*stride |
| 1554 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1555 |
} |
| 1556 |
strideTrack++ |
| 1557 |
if strideTrack >= stride { |
| 1558 |
strideTrack = 0 |
| 1559 |
innerStart += stride |
| 1560 |
} |
| 1561 |
innerStart++ |
| 1562 |
} |
| 1563 |
} |
| 1564 |
} |
| 1565 |
|
| 1566 |
func reduceDefaultUintptr(data, retVal []uintptr, dim0, dimSize, outerStride, stride, expected int, fn func(a, b uintptr) uintptr) { |
| 1567 |
for i := 0; i < dim0; i++ { |
| 1568 |
start := i * outerStride |
| 1569 |
sliced := data[start : start+outerStride] |
| 1570 |
var innerStart, strideTrack int |
| 1571 |
for j := 0; j < expected; j++ { |
| 1572 |
writeTo := i*expected + j |
| 1573 |
retVal[writeTo] = sliced[innerStart] |
| 1574 |
for k := 1; k < dimSize; k++ { |
| 1575 |
readFrom := innerStart + k*stride |
| 1576 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1577 |
} |
| 1578 |
strideTrack++ |
| 1579 |
if strideTrack >= stride { |
| 1580 |
strideTrack = 0 |
| 1581 |
innerStart += stride |
| 1582 |
} |
| 1583 |
innerStart++ |
| 1584 |
} |
| 1585 |
} |
| 1586 |
} |
| 1587 |
|
| 1588 |
func reduceDefaultF32(data, retVal []float32, dim0, dimSize, outerStride, stride, expected int, fn func(a, b float32) float32) { |
| 1589 |
for i := 0; i < dim0; i++ { |
| 1590 |
start := i * outerStride |
| 1591 |
sliced := data[start : start+outerStride] |
| 1592 |
var innerStart, strideTrack int |
| 1593 |
for j := 0; j < expected; j++ { |
| 1594 |
writeTo := i*expected + j |
| 1595 |
retVal[writeTo] = sliced[innerStart] |
| 1596 |
for k := 1; k < dimSize; k++ { |
| 1597 |
readFrom := innerStart + k*stride |
| 1598 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1599 |
} |
| 1600 |
strideTrack++ |
| 1601 |
if strideTrack >= stride { |
| 1602 |
strideTrack = 0 |
| 1603 |
innerStart += stride |
| 1604 |
} |
| 1605 |
innerStart++ |
| 1606 |
} |
| 1607 |
} |
| 1608 |
} |
| 1609 |
|
| 1610 |
func reduceDefaultF64(data, retVal []float64, dim0, dimSize, outerStride, stride, expected int, fn func(a, b float64) float64) { |
| 1611 |
for i := 0; i < dim0; i++ { |
| 1612 |
start := i * outerStride |
| 1613 |
sliced := data[start : start+outerStride] |
| 1614 |
var innerStart, strideTrack int |
| 1615 |
for j := 0; j < expected; j++ { |
| 1616 |
writeTo := i*expected + j |
| 1617 |
retVal[writeTo] = sliced[innerStart] |
| 1618 |
for k := 1; k < dimSize; k++ { |
| 1619 |
readFrom := innerStart + k*stride |
| 1620 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1621 |
} |
| 1622 |
strideTrack++ |
| 1623 |
if strideTrack >= stride { |
| 1624 |
strideTrack = 0 |
| 1625 |
innerStart += stride |
| 1626 |
} |
| 1627 |
innerStart++ |
| 1628 |
} |
| 1629 |
} |
| 1630 |
} |
| 1631 |
|
| 1632 |
func reduceDefaultC64(data, retVal []complex64, dim0, dimSize, outerStride, stride, expected int, fn func(a, b complex64) complex64) { |
| 1633 |
for i := 0; i < dim0; i++ { |
| 1634 |
start := i * outerStride |
| 1635 |
sliced := data[start : start+outerStride] |
| 1636 |
var innerStart, strideTrack int |
| 1637 |
for j := 0; j < expected; j++ { |
| 1638 |
writeTo := i*expected + j |
| 1639 |
retVal[writeTo] = sliced[innerStart] |
| 1640 |
for k := 1; k < dimSize; k++ { |
| 1641 |
readFrom := innerStart + k*stride |
| 1642 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1643 |
} |
| 1644 |
strideTrack++ |
| 1645 |
if strideTrack >= stride { |
| 1646 |
strideTrack = 0 |
| 1647 |
innerStart += stride |
| 1648 |
} |
| 1649 |
innerStart++ |
| 1650 |
} |
| 1651 |
} |
| 1652 |
} |
| 1653 |
|
| 1654 |
func reduceDefaultC128(data, retVal []complex128, dim0, dimSize, outerStride, stride, expected int, fn func(a, b complex128) complex128) { |
| 1655 |
for i := 0; i < dim0; i++ { |
| 1656 |
start := i * outerStride |
| 1657 |
sliced := data[start : start+outerStride] |
| 1658 |
var innerStart, strideTrack int |
| 1659 |
for j := 0; j < expected; j++ { |
| 1660 |
writeTo := i*expected + j |
| 1661 |
retVal[writeTo] = sliced[innerStart] |
| 1662 |
for k := 1; k < dimSize; k++ { |
| 1663 |
readFrom := innerStart + k*stride |
| 1664 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1665 |
} |
| 1666 |
strideTrack++ |
| 1667 |
if strideTrack >= stride { |
| 1668 |
strideTrack = 0 |
| 1669 |
innerStart += stride |
| 1670 |
} |
| 1671 |
innerStart++ |
| 1672 |
} |
| 1673 |
} |
| 1674 |
} |
| 1675 |
|
| 1676 |
func reduceDefaultStr(data, retVal []string, dim0, dimSize, outerStride, stride, expected int, fn func(a, b string) string) { |
| 1677 |
for i := 0; i < dim0; i++ { |
| 1678 |
start := i * outerStride |
| 1679 |
sliced := data[start : start+outerStride] |
| 1680 |
var innerStart, strideTrack int |
| 1681 |
for j := 0; j < expected; j++ { |
| 1682 |
writeTo := i*expected + j |
| 1683 |
retVal[writeTo] = sliced[innerStart] |
| 1684 |
for k := 1; k < dimSize; k++ { |
| 1685 |
readFrom := innerStart + k*stride |
| 1686 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1687 |
} |
| 1688 |
strideTrack++ |
| 1689 |
if strideTrack >= stride { |
| 1690 |
strideTrack = 0 |
| 1691 |
innerStart += stride |
| 1692 |
} |
| 1693 |
innerStart++ |
| 1694 |
} |
| 1695 |
} |
| 1696 |
} |
| 1697 |
|
| 1698 |
func reduceDefaultUnsafePointer(data, retVal []unsafe.Pointer, dim0, dimSize, outerStride, stride, expected int, fn func(a, b unsafe.Pointer) unsafe.Pointer) { |
| 1699 |
for i := 0; i < dim0; i++ { |
| 1700 |
start := i * outerStride |
| 1701 |
sliced := data[start : start+outerStride] |
| 1702 |
var innerStart, strideTrack int |
| 1703 |
for j := 0; j < expected; j++ { |
| 1704 |
writeTo := i*expected + j |
| 1705 |
retVal[writeTo] = sliced[innerStart] |
| 1706 |
for k := 1; k < dimSize; k++ { |
| 1707 |
readFrom := innerStart + k*stride |
| 1708 |
retVal[writeTo] = fn(retVal[writeTo], sliced[readFrom]) |
| 1709 |
} |
| 1710 |
strideTrack++ |
| 1711 |
if strideTrack >= stride { |
| 1712 |
strideTrack = 0 |
| 1713 |
innerStart += stride |
| 1714 |
} |
| 1715 |
innerStart++ |
| 1716 |
} |
| 1717 |
} |
| 1718 |
} |