Skip to content

Pretty printing of matrices (and multidimensional arrays) #40

Open
@certik

Description

@certik

Currently the standard Fortran's print *, A prints a 2D array A as a 1D list of numbers. Rather, I would like stdlib to have a function print_array (we can discuss a better name) that would print the array as NumPy:

>>> numpy.arange(10000).reshape(250,40)
array([[   0,    1,    2, ...,   37,   38,   39],
       [  40,   41,   42, ...,   77,   78,   79],
       [  80,   81,   82, ...,  117,  118,  119],
       ..., 
       [9880, 9881, 9882, ..., 9917, 9918, 9919],
       [9920, 9921, 9922, ..., 9957, 9958, 9959],
       [9960, 9961, 9962, ..., 9997, 9998, 9999]])

or Julia:

julia> B = [1 2; 3 4; 5 6; 7 8; 9 10]
5×2 Array{Int64,2}:
 1   2
 3   4
 5   6
 7   8
 9  10

Julia can also use nice unicode characters for ... and vertical ... if the array is too large.

Then we should use this function at

subroutine print_array(a)
and other places.

Then compilers can perhaps optionally use such print_array as default in the Fortran's language print statement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    easyDifficulty level is easy and good for starting into this projectgood first issueGood for newcomersin progressThis proposal is being worked ontopic: utilitiescontainers, strings, files, OS/environment integration, unit testing, assertions, logging, ...

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions