Code Monkey home page Code Monkey logo

scaledarrays.jl's Introduction

ScaledArrays

Build Status Build Status

Store both an Array A and a scale s together in a ScaledArray SA = s*A, such that for example SA1*SA2 = (s1*s2)*A1*A2. The arrays are supposed to have elements O(1), whereas the scale s is supposed to carry the magnitude.

Use unscale to unscale SA (i.e. s=1) and rescale to change s.

Example

julia> using ScaledArrays

julia> SA = ScaledArray(rand(3,3),100)
3×3 ScaledArray{Float64,2}:
 0.354352  0.360733  0.0441772
 0.39473   0.499311  0.560835
 0.392939  0.245807  0.0387673

julia> unscale(SA)
3×3 ScaledArray{Float64,2}:
 35.4352  36.0733   4.41772
 39.473   49.9311  56.0835
 39.2939  24.5807   3.87673

julia> rescale(SA,2)
3×3 ScaledArray{Float64,2}:
 17.7176  18.0367   2.20886
 19.7365  24.9655  28.0417
 19.647   12.2903   1.93837

julia> SA² = SA*SA
3×3 ScaledArray{Float64,2}:
 0.285316  0.318804  0.219679
 0.55734   0.529561  0.319211
 0.251499  0.27401   0.156719

julia> SA².s
10000.0

scaledarrays.jl's People

Contributors

milankl avatar

Watchers

James Cloos avatar  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.