boostorg / boostorg/python

Create diagonal matrix in python::numpy

Offen
#255 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
537
Forks
223
Ø Merge
11 Std. 22 Min.
Gemergte PRs (30 T.)
2

Beschreibung

This is probably a feature request.
What is the correct way to create diagonal matrix in boost::python::numpy?

Of course, I can just create a usual 2D matrix then assign its diagonal. But is there a better way?

It seems that in numpy (in python), the diagonal matrix is stored in a compact format, e.g. only stores the diagonal data. This can be observed by `a = np.diag(np.random.rand(20000,1))` and watch the memory usage. (much smaller than 20000^2 * 8 / 2^20 MB)

It would be nice to have a method to build diagonal matrix in this "compact" format.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.