gitee.com/quant1x/num@v0.3.2/dot_test.go (about)

     1  package num
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestDot2D(t *testing.T) {
     9  	// https://blog.csdn.net/llittleSun/article/details/115045660
    10  	//
    11  	//a := [][]int{{1, 2}, {3, 7}}
    12  	//b := [][]int{{4, 3}, {5, 0}}
    13  	//
    14  	//c := Dot2D(a, b)
    15  	//fmt.Println(c)
    16  
    17  	A := [][]int{{1, 4, 9}, {1, 2, 3}, {1, 1, 1}}
    18  	fmt.Println("A =", A)
    19  	B := [][]int{{1, 1, 1}, {4, 2, 1}, {9, 3, 1}}
    20  	fmt.Println("B =", B)
    21  	C := Dot2D(A, B)
    22  	fmt.Println("C =", C)
    23  }
    24  
    25  func TestDot(t *testing.T) {
    26  	A := [][]int{{1, 4, 9}, {1, 2, 3}, {1, 1, 1}}
    27  	A = [][]int{{1, 4, 9, 16, 25}, {1, 2, 3, 4, 5}, {1, 1, 1, 1, 1}}
    28  	B := Transpose2D(A)
    29  	fmt.Println("A =", A)
    30  	fmt.Println("B =", B)
    31  	C := Dot(A, B)
    32  	fmt.Println("C =", C)
    33  }