- Machine Learning With Go
- Daniel Whitenack
- 181字
- 2021-07-08 10:37:31
Vectors
A vector is an ordered collection of numbers arranged in either a row (left to right) or column (up and down). Each of the numbers in a vector is called a component. This might be, for example, a collection of numbers that represents our company sales, or it might be a collection of numbers representing temperatures.
It's, of course, natural for us to use Go slices to represent these ordered collections of data, as follows:
// Initialize a "vector" via a slice.
var myvector []float64
// Add a couple of components to the vector.
myvector = append(myvector, 11.0)
myvector = append(myvector, 5.2)
// Output the results to stdout.
fmt.Println(myvector)
Slices are indeed ordered collections. However, they don't really represent the concept of rows or columns, and we would still need to work out various vector operations on top of slices. Thankfully, on the vector operation side, gonum provides gonum.org/v1/gonum/floats to operate on slices of float64 values and gonum.org/v1/gonum/mat, which, along with matrices, provides a Vector type (with corresponding methods):
// Create a new vector value.
myvector := mat.NewVector(2, []float64{11.0, 5.2})
- 手機安全和可信應用開發指南:TrustZone與OP-TEE技術詳解
- Mastering JavaScript Functional Programming
- SQL學習指南(第3版)
- 軟件測試項目實戰之性能測試篇
- Django Design Patterns and Best Practices
- Mastering Ubuntu Server
- Linux命令行與shell腳本編程大全(第4版)
- Jupyter數據科學實戰
- Visual C#.NET程序設計
- HTML5從入門到精通 (第2版)
- JavaScript程序設計(第2版)
- 算法圖解
- Machine Learning for OpenCV
- Java并發實現原理:JDK源碼剖析
- Mastering ArcGIS Server Development with JavaScript