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

Bug 663

Summary: Permit NoChange in setZero, setOnes, setConstant, setRandom
Product: Eigen Reporter: Rhys Ulerich <rhys.ulerich>
Component: Core - generalAssignee: Nobody <eigen.nobody>
Status: CONFIRMED ---    
Severity: enhancement CC: gael.guennebaud, jacob.benoit.1, pw_eigen
Priority: Normal Keywords: JuniorJob
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 814    
Attachments:
Description Flags
Patch for Bug 663 none

Description Rhys Ulerich 2013-09-25 18:50:21 UTC
If feasible, please consider permitting NoChange as an argument in either the rows or cols slots within the following methods:

x.setZero(rows, cols);
x.setOnes(rows, cols);
x.setConstant(rows, cols, value);
x.setRandom(rows, cols);

That is, the LHS and RHS of the following equalities would behave identically:

x.setZero(NoChange, cols) "==" x.setZero(x.rows(), cols)
x.setZero(rows, NoChange) "==" x.setZero(rows, x.cols())

x.setOnes(NoChange, cols) "==" x.setOnes(x.rows(), cols)
x.setOnes(rows, NoChange) "==" x.setOnes(rows, x.cols())

x.setConstant(NoChange, cols, value) "==" x.setConstant(x.rows(), cols, value)
x.setConstant(rows, NoChange, value) "==" x.setConstant(rows, x.cols(), value)

x.setRandom(NoChange, cols) "==" x.setRandom(x.rows(), cols)
x.setRandom(rows, NoChange) "==" x.setRandom(rows, x.cols())

These would be handy when "x" is complicated to express.  Feel free to close as irrelevant if I'm missing some portion of the API that handles this succinctly.
Comment 1 Gael Guennebaud 2013-10-28 17:27:46 UTC
This should not be difficult to add, and a welcome addition for consistency.  Patch welcome.

In the meantime you can do:

X.resize(NoChange, cols); X.setConstant(2);

which is not much more verbose.
Comment 2 Gael Guennebaud 2016-01-31 13:08:15 UTC
Not critical, but good junior-job. So let's keep it for newcomers.
Comment 3 Philipp Wissmann 2016-03-11 15:43:21 UTC
Created attachment 666 [details]
Patch for Bug 663

I've added support for NoChange in the functions mentioned above.

Please have a look at it.

Philipp
Comment 4 Nobody 2019-12-04 12:38:31 UTC
-- 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/663.