This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 663 - Permit NoChange in setZero, setOnes, setConstant, setRandom
Summary: Permit NoChange in setZero, setOnes, setConstant, setRandom
Status: CONFIRMED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: unspecified
Hardware: All All
: Normal enhancement
Assignee: Nobody
URL:
Whiteboard:
Keywords: JuniorJob
Depends on:
Blocks: 3.4
  Show dependency treegraph
 
Reported: 2013-09-25 18:50 UTC by Rhys Ulerich
Modified: 2019-12-04 12:38 UTC (History)
3 users (show)



Attachments
Patch for Bug 663 (13.68 KB, patch)
2016-03-11 15:43 UTC, Philipp Wissmann
no flags Details | Diff

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.

Note You need to log in before you can comment on or make changes to this bug.