- 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})
- Flask Blueprints
- Python深度學習
- Learning Flask Framework
- Learning SQLite for iOS
- Python 3網絡爬蟲實戰
- Learning Python Design Patterns
- PhoneGap:Beginner's Guide(Third Edition)
- 零基礎學單片機C語言程序設計
- R Data Analysis Cookbook(Second Edition)
- RSpec Essentials
- Create React App 2 Quick Start Guide
- Unity 2017 Mobile Game Development
- Node學習指南(第2版)
- Java 11 and 12:New Features
- Java Script從入門到精通(第5版)