Giter Site home page Giter Site logo

tensors.jl's Introduction

Tensors.jl

Testing out a design for ITensor using an internal Tensor type.

The Tensor class is meant to have a Julia AbstractArray interface, but with various types of storage and indices (i.e. the storage could be Diag or BlockSparse and the indices could be tuples of integers or ITensor Indices).

ITensor functions are written by creating Tensor objects from their storage and indices and then calling Tensor functions, using a function-barrier approach.

Here is a sample of some current capabilities:

include("itensor.jl")

#
# Test the Tensor class
#

TA = Tensor(Dense([1 2; 3 4]),(2,2))
TB = Tensor(Diag([1,2]),(2,2))

@show TA[1,2] == 2
@show TB[2,2] == 2
@show TB[1,2] == 0
@show permutedims(TA,(2,1))
@show TC = TA+TB
@show add_permute(TA,TB,(2,1))

#
# Test the ITensor class
#

i = Index(2,"i")
j = Index(2,"j")

A = ITensor([1 2; 3 4],i,j)
B = diagITensor([1,2],i,j)

@show A[i(1),j(2)]
@show A[j(2),i(1)]
@show B[i(1),j(1)]
@show B[i(1),j(2)]

@show Ap = permute(A,j,i)

@show A[i(1),j(2)] == Ap[i(1),j(2)]

@show C = A+Ap

This code is in the run.jl script in the repository.

tensors.jl's People

Contributors

mtfishman avatar

Stargazers

ForFun avatar M Sidik Augi Rahmat 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.