[erlang-questions] Generating a list of lists containing random numbers

zxq9@REDACTED zxq9@REDACTED
Tue Jul 3 09:24:10 CEST 2018


On 2018年7月3日火曜日 16時08分18秒 JST zxq9@REDACTED wrote:
> On 2018年7月3日火曜日 8時33分12秒 JST Raimo Niskanen wrote:
> > On Tue, Jul 03, 2018 at 01:15:17PM +0900, zxq9@REDACTED wrote:
> > > On 2018年7月2日月曜日 23時36分10秒 JST Awsaf Rahman wrote:
> > > > Hello!
> > > > 
> > > > I am trying to determine the execution time for my matrix multiplication
> > > > program and for that I need to generate a large enough List of Lists of
> > > > random integers. Say I want to generate a matrix with a 1000 rows (that is
> > > > 1000 lists inside a list). Is there any way of doing it? I can generate a
> > > > list of random numbers using list comprehension but can't figure out how to
> > > > go about building a list of lists.
> > > 
> > > Wheels within wheels, man...
> > 
> > This may be a missing function for the lists module:
> 
> I think I'd rather have matrix operations in a matrix module.
> 
...
>
> Would people be interested in a matrix_math library?

I figured I could do a search and just find a native Erlang lib for this.

Sadly, all I found in native Erlang was:

1- My blog post about matrix rotation and multiplication I mentioned
earlier (evidently I posted it here https://zxq9.com/archives/1387 --
in all it's naive and assumptive glory)

2- A similar module that does a bit more but assumes a bit more as well
https://github.com/majelbstoat/Morgana/blob/master/src/matrix.erl

3- A module that looks like it was intended as an escript that sort of
freaks me out:
http://dada.perl.it/shootout/matrix.erlang.html

Not very comprehensive.

The more comprehensive solutions are bindings to C/C++ libs like BLAS
over CUDA, which are fine as long as you can build and run C/C++ code,
but NIFs are not easy to deal with for anyone not running on *nix:
https://github.com/vascokk/NumEr

Hm.

It seems like if there were a need for this that it would be covered
already. Is it too niche to worry with?

-Craig



More information about the erlang-questions mailing list