Giter VIP home page Giter VIP logo

stenglib's People

Contributors

stefanengblom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

stenglib's Issues

Using fsparse in Matlab

Greetings, I am new to this and having hard time running fsparse.m in MATLAB. Can you please guide on how to use it or how to fully install the Fast package?

Generating large sparse matrices

When generating large matrices it can happen that the number of elements is larger then the max value that can be stored in "int" format. If this happens I use the workaround below to generate the matrix in multiple steps. However this is not ideal. Can the "int" limitation be changed into "long" or would this result in other problems?

if length(MyRowIdx) > intmax('int32')
    
    Idx = false(length(MyRowIdx),1);
    Idx( 1 : intmax('int32') ) = true;
    H = fsparse(MyRowIdx(Idx), MyColIdx(Idx), Val(Idx), [numElem, numElem]);
    
    MyRowIdx(Idx) = [];
    MyColIdx(Idx) = [];
    Val(Idx) = [];
    
    while any(MyRowIdx)
        
        Idx = false(length(MyRowIdx),1);
        Idx( 1 : min( length(MyRowIdx) , intmax('int32') ) ) = true;
        
        H = H + fsparse(MyRowIdx(Idx), MyColIdx(Idx), Val(Idx), [numElem, numElem]);
        
        MyRowIdx(Idx) = [];
        MyColIdx(Idx) = [];
        Val(Idx) = [];
        
    end
    
else
    % we can generate the matrix in a single fsparse call
    H = fsparse(MyRowIdx, MyColIdx, Val, [numElem, numElem]);
end

move make.m up a directory

Dear Stefan,
Just to let you know I had to move make.m up a directory from Fast/source to Fast/ since it expects to look into pwd / source. Then it built fine. I'm on ubuntu 16.04 linux, Matlab R2017a.

But on 4-core i7 it doesn't beat the native matlab by much (here openmp=true):

% test speed of forming sparse mats, including stenglib. Barnett 10/10/18
addpath ~/matlab/stenglib/Fast
clear
n = 1e5;
nnz = 3e7;
i=randi(n,nnz,1);
j=randi(n,nnz,1);
a = rand(nnz,1);
tic; A = sparse(i,j,a,n,n); toc % single thread
tic; A = fsparse(i,j,a,[n,n,nnz]); toc % is multi thread
tic; A = fsparse(i,j,a,[n,n,nnz],'nosort'); toc % seems single thread
tic; [i,x]=sort(i); j=j(x);a=a(x); A = fsparse(i,j,a,[n,n,nnz]); toc % slowest
tic; A = fsparse(i,j,a,[n,n,nnz]); toc % after sort, fast

Elapsed time is 4.991984 seconds.
Elapsed time is 3.538113 seconds.
Elapsed time is 3.828368 seconds.
Elapsed time is 5.219050 seconds.
Elapsed time is 1.020627 seconds.

With openmp off the 'nosort' case is still 4.4 s, ie faster than matlab.

I imagine this is because it's memory-bandwidth limited. I'll try xeon next. Anyway, thanks for writing it!
Alex

Repeat vs Repelem

Hi Stefan,

thanks a lot for you awesome library! I'm using it a lot.
Just a minor question: Did you compare your repeat function with MATLAB's repelem? If I'm not mistaken they are doing something very similar. repelem also seems to be native code.

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.