- 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})
- 數據結構(Java語言描述)
- Julia高性能科學計算(第2版)
- Mastering openFrameworks:Creative Coding Demystified
- Python Data Structures and Algorithms
- 小型編譯器設計實踐
- Emgu CV Essentials
- Mastering Apache Storm
- 從Excel到Python數據分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應用
- Python趣味編程與精彩實例
- Android系統下Java編程詳解
- WordPress Search Engine Optimization(Second Edition)
- Apache Kafka 1.0 Cookbook
- 大話程序員:從入門到優秀全攻略
- Visual FoxPro數據庫程序設計
- PHP編程(第4版)