Coder Social home page Coder Social logo

numgo's Introduction

numgo

##is a small numpy-like module for my own use. use gonum instead

Build Status Code Coverage Go Report Card GoDoc

###usage:

import (
  "fmt"
  "pa-m/numgo"
)

var np = numgo.NumGo{}

func fl(d ...float64) []float64 {
	return d
}

func Example() {
	fmt.Println("zeros:", np.Zeros([]int{3}))
	fmt.Println("ones:", np.Ones([]int{3}))
	fmt.Println("sum:", np.Sum(fl(1., 2., 3.)))
	fmt.Println("min:", np.Min(fl(1., 2., 3.)))
	fmt.Println("max:", np.Max(fl(1., 2., 3.)))
	fmt.Println("mean:", np.Mean(fl(1., 2., 3.)))
	fmt.Println("minimum:", np.Minimum(fl(1., 2., 3.), fl(2., 2., 2.)))
	fmt.Println("maximum:", np.Maximum(fl(1., 2., 3.), fl(2., 2., 2.)))
	fmt.Println("linspace:", np.Linspace(-5., 5., 11, true), np.Linspace(-5, 5, 10, false))
	fmt.Println("logspace:", np.Logspace(-5., 5., 11, true, 10.), np.Logspace(-5, 5, 10, false, 10.))
	fmt.Println("argsort:", np.Argsort(fl(1., 3., 2.)))
	fmt.Println("argmin:", np.Argmin(fl(1., 3., 2.)))
	fmt.Println("argmax:", np.Argmax(fl(1., 3., 2.)))
	fmt.Println("add:", np.Add(fl(1., 2., 3.), fl(1., 2., 3.)))
	fmt.Println("sub:", np.Sub(fl(1., 2., 3.), fl(1., 2., 3.)))
	fmt.Println("multiply:", np.Multiply(fl(1., 2., 3.), fl(1., 2., 3.)))
	fmt.Println("divide:", np.Divide(fl(1., 2., 3.), fl(1., 2., 3.)))
	fmt.Println("square:", np.Square(fl(1., 2., 3.)))
	// Output:
	// zeros: [0 0 0]
	// ones: [1 1 1]
	// sum: 6
	// min: 1
	// max: 3
	// mean: 2
	// minimum: [1 2 2]
	// maximum: [2 2 3]
	// linspace: [-5 -4 -3 -2 -1 0 1 2 3 4 5] [-5 -4 -3 -2 -1 0 1 2 3 4]
	// logspace: [1e-05 0.0001 0.001 0.01 0.1 1 10 100 1000 10000 100000] [1e-05 0.0001 0.001 0.01 0.1 1 10 100 1000 10000]
	// argsort: [0 2 1]
	// argmin: 0
	// argmax: 1
	// add: [2 4 6]
	// sub: [0 0 0]
	// multiply: [1 4 9]
	// divide: [1 1 1]
	// square: [1 4 9]
}

numgo's People

Contributors

kbakdev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.