Bugzilla – Full Text Bug Listing

This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Summary: | "static" / local storage on stack | ||
---|---|---|---|

Product: | Eigen | Reporter: | Enrico <hshixun> |

Component: | Documentation | Assignee: | Nobody <eigen.nobody> |

Status: | RESOLVED FIXED | ||

Severity: | Unknown | CC: | chtz, gael.guennebaud, jacob.benoit.1, jitseniesen |

Priority: | Normal | ||

Version: | 3.0 | ||

Hardware: | All | ||

OS: | All | ||

Whiteboard: |

Description
Enrico
2013-06-17 12:26:14 UTC
yes, you are right, we should speak about stack-based allocation rather than static allocation. Actually, we can't say much about allocation, because you can still allocate fixed-sized matrices on the heap, the stack or statically. Maybe "plain static-sized array" is the term we are looking for? As an alternative, the std::array documentation here http://www.cplusplus.com/reference/array/array/ uses the phrase "ordinary array declared with the language's bracket syntax ([])". Maybe that is a bit too layman-ish but every C/C++ programmer should clearly understand that. It's not easy to describe correctly and concisely. I guess the best term depends on the context. Going through the three cases flagged up, with my attempt to rewrite them: OLD TEXT: "A default constructor is always available, never performs any dynamic memory allocation, and never initializes the matrix coefficients. You can do: Matrix3f a; MatrixXf b; Here, * a is a 3x3 matrix, with a static float[9] array of uninitialized coefficients, * b is a dynamic-size matrix whose size is currently 0x0, and whose array of coefficients hasn't yet been allocated at all." REWRITE: "[...] a is a 3x3 matrix whose array of coefficients is allocated automatically but not initialized, similar to when you write <code>float a[9]</code> [...]" [ This ignores what happens when it is a global variable. I believe "automatic allocation" is a technical term but I'm not sure how widespread it is. ] ------------------------ OLD TEXT: "Internally, a fixed-size Eigen matrix is just a plain static array, i.e. doing Matrix4f mymatrix; really amounts to just doing float mymatrix[16]; so this really has zero runtime cost" REWRITE: Just remove "static", I think it's clear enough without it ------------------------ OLD TEXT: "Worse, trying to create a very large matrix using fixed sizes could result in a stack overflow, since Eigen will try to allocate the array as a static array, which by default goes on the stack." REWRITE: "Worse, trying to create a very large matrix using fixed sizes inside a function could result in a stack overflow, since Eigen will try to allocate the array automatically as a local variable, and this is normally done on the stack." (In reply to comment #3) > * a is a 3x3 matrix, with a static float[9] array of uninitialized > coefficients, > > REWRITE: > > "[...] a is a 3x3 matrix whose array of coefficients is allocated automatically > but not initialized, similar to when you write <code>float a[9]</code> [...]" > > [ This ignores what happens when it is a global variable. I believe "automatic > allocation" is a technical term but I'm not sure how widespread it is. ] How about just replacing "static" by "plain"? To me "automatic allocation" sounds more as if the class calls new and free automatically (contradicting the part after the comma). I agree on the other two. Yes, I agree with that. I now pushed this change. changeset: 5357:9d9a060aae44 date: Tue Jun 18 14:35:12 2013 +0100 summary: Avoid phrase "static allocation" for local storage on stack (bug 615). -- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/615. |