bug-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gsl] Minor improvement to gsl_spmatrix.h suggested


From: Schmitz Manuel (LBC)
Subject: [Bug-gsl] Minor improvement to gsl_spmatrix.h suggested
Date: Fri, 22 Dec 2017 16:44:01 +0000

Dear Sirs,

in gsl_spmatrix.h, the struct "gsl_spmatrix" gets defined:

typedef struct
{
                ...
                void* work;
                ...
} gsl_spmatrix;

I am suggesting to replace the member "work" by a union:

typedef struct
{
                ...
                union {
                               void * work;
                               size_t * work_sze;
                               double * work_dbl;
};
...
} gsl_spmatrix;

This has the following benefits:

-          This can avoid (nasty) casts when using the working memory later. 
Unions are considered to be safer than casts.

-          This can avoid compiler warnings about casts when using high warning 
levels.

-          It better expresses the intent: "work" shall be used as a buffer for 
"double" or for "size_t".

-          The change does not break the existing interface.

-          The runtime overhead is zero and the compile-time overhead is 
neglectable.

Best regards

i.A. Manuel Schmitz

TE-Krantechnik/Berechnung

Liebherr-Werk Biberach GmbH
PO Box 16 63
88396 Biberach an der Riss
Germany
Phone: +49 (7351) 414639
Fax: +49 (7351) 412879
address@hidden<mailto:address@hidden>
www.liebherr.com<http://www.liebherr.com>

Chairman of the supervisory board: Stefan Heissler
Managing directors: Dipl.-Ing. (FH) Marco Guariglia, Dipl.-Ing. Günther 
Hardock, Dr. Thomas Schwaninger, Dipl.-Ing. Dominique Tasch
Registered business address: 88400 Biberach an der Riss, Memminger Straße 120
Court of jurisdiction: Amtsgericht Ulm HRB 640075, USt-Id Nr. DE811120028

This email may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this email in error) please notify 
the sender immediately and destroy this email. Any unauthorized copying, 
disclosure or distribution of the material in this email is strictly forbidden.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]