gitee.com/quant1x/num@v0.3.2/asm/c2goasm/test/MultiplyAndAdd_test.go (about)

     1  package c2goasmtest
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestMultiplyAndAdd(t *testing.T) {
     8  
     9  	f1 := [8]float32{}
    10  	f2 := [8]float32{}
    11  	f3 := [8]float32{}
    12  
    13  	for i := 0; i < 8; i++ {
    14  		f1[i] = float32(i)
    15  		f2[i] = float32(i * 2)
    16  		f3[i] = float32(i * 3)
    17  	}
    18  
    19  	f4 := MultiplyAndAdd(&f1, &f2, &f3)
    20  
    21  	for i := 0; i < 8; i++ {
    22  		expected := f1[i]*f2[i] + f3[i]
    23  		if f4[i] != expected {
    24  			t.Errorf("TestMultiplyAndAdd(): \nexpected %f\ngot      %f", expected, f4[i])
    25  		}
    26  	}
    27  }