[jira] [Commented] (MATH-646) Unmodifiable views of RealVector
[ https://issues.apache.org/jira/browse/MATH-646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13090164#comment-13090164 ] Gilles commented on MATH-646: - Committed, with some small changes, in revision 1161064. Before posting a patch, please don't forget to look at the output of mvn clean site for Javadoc warnings and at checkstyle.html (in target/site). Couldn't we call the unmodifiableRealVector method simply unmodifiableVector? Unmodifiable views of RealVector Key: MATH-646 URL: https://issues.apache.org/jira/browse/MATH-646 Project: Commons Math Issue Type: New Feature Affects Versions: 3.0 Reporter: Sébastien Brisard Labels: linear, vector Attachments: MATH-646.patch, MATH-646.patch The issue has been discussed on the [mailing list|http://mail-archives.apache.org/mod_mbox/commons-dev/201108.mbox/CAGRH7HqxUb2y1HmFt9VJ-kxsXwipk_MdO0D=rnuazmgpnot...@mail.gmail.com]. Please find attached a proposal for a new class {{UnmodifiableRealVector}}. I chose not to nest it in {{AbstractRealVector}} because it would make the corresponding file huge. Therefore, {{UnmodifiableRealVector}} is {{final}}. Maybe you'd like it to be {{private}} as well? A static method is provided in {{AbstractRealVector}} to build an {{UnmodifiableRealVector}} from any {{RealVector}}. Tests are also provided. Since iterating through different implementations of {{RealVector}} is actually different, a test is provided for {{UnmodifiableRealVector}} built on {{ArrayRealVector}} and {{OpenMapRealVector}}. These tests both derive from the same abstract test class. Hope everything works fine. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (MATH-646) Unmodifiable views of RealVector
[ https://issues.apache.org/jira/browse/MATH-646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13090179#comment-13090179 ] Sébastien Brisard commented on MATH-646: {quote} Before posting a patch, please don't forget to look at the output of mvn clean site for Javadoc warnings and at checkstyle.html (in target/site). {quote} I'm sorry, I'll do that next time. I must have mis-configured checkstyle in my Eclipse. Sorry again to waste your time. {quote} Couldn't we call the unmodifiableRealVector method simply unmodifiableVector? {quote} I'm all for it. While we are at it, shouldn't we provide an unmodifiable view of matrices, following the same lines? Shall I open a JIRA ticket? Unmodifiable views of RealVector Key: MATH-646 URL: https://issues.apache.org/jira/browse/MATH-646 Project: Commons Math Issue Type: New Feature Affects Versions: 3.0 Reporter: Sébastien Brisard Labels: linear, vector Attachments: MATH-646.patch, MATH-646.patch The issue has been discussed on the [mailing list|http://mail-archives.apache.org/mod_mbox/commons-dev/201108.mbox/CAGRH7HqxUb2y1HmFt9VJ-kxsXwipk_MdO0D=rnuazmgpnot...@mail.gmail.com]. Please find attached a proposal for a new class {{UnmodifiableRealVector}}. I chose not to nest it in {{AbstractRealVector}} because it would make the corresponding file huge. Therefore, {{UnmodifiableRealVector}} is {{final}}. Maybe you'd like it to be {{private}} as well? A static method is provided in {{AbstractRealVector}} to build an {{UnmodifiableRealVector}} from any {{RealVector}}. Tests are also provided. Since iterating through different implementations of {{RealVector}} is actually different, a test is provided for {{UnmodifiableRealVector}} built on {{ArrayRealVector}} and {{OpenMapRealVector}}. These tests both derive from the same abstract test class. Hope everything works fine. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (MATH-646) Unmodifiable views of RealVector
[ https://issues.apache.org/jira/browse/MATH-646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13090190#comment-13090190 ] Gilles commented on MATH-646: - For unmodifiableRealVector - unmodifiableVector, I can do it; I was just wondering whether there could be any side-effects (like the risk of having another method like this in the future) or whether it would be better to have a suffix that is exactly the name of the returned type... For the matrix view, do you have a need for it now? If not, it could be delayed to 3.1 and, if you want, you could tackle issues that must be resolved before 3.0. Unmodifiable views of RealVector Key: MATH-646 URL: https://issues.apache.org/jira/browse/MATH-646 Project: Commons Math Issue Type: New Feature Affects Versions: 3.0 Reporter: Sébastien Brisard Labels: linear, vector Attachments: MATH-646.patch, MATH-646.patch The issue has been discussed on the [mailing list|http://mail-archives.apache.org/mod_mbox/commons-dev/201108.mbox/CAGRH7HqxUb2y1HmFt9VJ-kxsXwipk_MdO0D=rnuazmgpnot...@mail.gmail.com]. Please find attached a proposal for a new class {{UnmodifiableRealVector}}. I chose not to nest it in {{AbstractRealVector}} because it would make the corresponding file huge. Therefore, {{UnmodifiableRealVector}} is {{final}}. Maybe you'd like it to be {{private}} as well? A static method is provided in {{AbstractRealVector}} to build an {{UnmodifiableRealVector}} from any {{RealVector}}. Tests are also provided. Since iterating through different implementations of {{RealVector}} is actually different, a test is provided for {{UnmodifiableRealVector}} built on {{ArrayRealVector}} and {{OpenMapRealVector}}. These tests both derive from the same abstract test class. Hope everything works fine. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (MATH-646) Unmodifiable views of RealVector
[ https://issues.apache.org/jira/browse/MATH-646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13090254#comment-13090254 ] Sébastien Brisard commented on MATH-646: I could use unmodifiable views of matrices, but I'm happy implementing it outside the o.a.c.m library for the time being, and submitting it later on. I can then concentrate on other issues. I guess MATH-581 is still scheduled for 3.0 (support for iterative linear solvers)? Unmodifiable views of RealVector Key: MATH-646 URL: https://issues.apache.org/jira/browse/MATH-646 Project: Commons Math Issue Type: New Feature Affects Versions: 3.0 Reporter: Sébastien Brisard Labels: linear, vector Attachments: MATH-646.patch, MATH-646.patch The issue has been discussed on the [mailing list|http://mail-archives.apache.org/mod_mbox/commons-dev/201108.mbox/CAGRH7HqxUb2y1HmFt9VJ-kxsXwipk_MdO0D=rnuazmgpnot...@mail.gmail.com]. Please find attached a proposal for a new class {{UnmodifiableRealVector}}. I chose not to nest it in {{AbstractRealVector}} because it would make the corresponding file huge. Therefore, {{UnmodifiableRealVector}} is {{final}}. Maybe you'd like it to be {{private}} as well? A static method is provided in {{AbstractRealVector}} to build an {{UnmodifiableRealVector}} from any {{RealVector}}. Tests are also provided. Since iterating through different implementations of {{RealVector}} is actually different, a test is provided for {{UnmodifiableRealVector}} built on {{ArrayRealVector}} and {{OpenMapRealVector}}. These tests both derive from the same abstract test class. Hope everything works fine. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (MATH-646) Unmodifiable views of RealVector
[ https://issues.apache.org/jira/browse/MATH-646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13085303#comment-13085303 ] Sébastien Brisard commented on MATH-646: {quote} Rather than an issue of large source file, the issue is whether this class should part of the public API. Personally I think that it shouldn't {quote} I agree, that's the reason why I suggested we make this class private. No problem, I'll make it a nested, anonymous class within the {{unmodifiableRealVector()}} method. {quote} I'm suspicious that it is possible to call setIndex on the supposedly unmodifiable entry. Maybe that it is harmless? {quote} I have checked that calling {{setIndex}} is indeed harmless while iterating over the vector in question. However, in my view, this method sould not be visible. Thanks for your detailed review of the code. I'll have these errors corrected by the end of this week, if that's OK with you. Unmodifiable views of RealVector Key: MATH-646 URL: https://issues.apache.org/jira/browse/MATH-646 Project: Commons Math Issue Type: New Feature Affects Versions: 3.0 Reporter: Sébastien Brisard Labels: linear, vector Attachments: MATH-646.patch The issue has been discussed on the [mailing list|http://mail-archives.apache.org/mod_mbox/commons-dev/201108.mbox/CAGRH7HqxUb2y1HmFt9VJ-kxsXwipk_MdO0D=rnuazmgpnot...@mail.gmail.com]. Please find attached a proposal for a new class {{UnmodifiableRealVector}}. I chose not to nest it in {{AbstractRealVector}} because it would make the corresponding file huge. Therefore, {{UnmodifiableRealVector}} is {{final}}. Maybe you'd like it to be {{private}} as well? A static method is provided in {{AbstractRealVector}} to build an {{UnmodifiableRealVector}} from any {{RealVector}}. Tests are also provided. Since iterating through different implementations of {{RealVector}} is actually different, a test is provided for {{UnmodifiableRealVector}} built on {{ArrayRealVector}} and {{OpenMapRealVector}}. These tests both derive from the same abstract test class. Hope everything works fine. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (MATH-646) Unmodifiable views of RealVector
[ https://issues.apache.org/jira/browse/MATH-646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13085329#comment-13085329 ] Gilles commented on MATH-646: - There must be one public (or with package access) class in each Java source file. But you can have additional ones (without access qualifier), not necessarily nested. Thus, in AbstractRealVector.java: {code} public class AbstractRealVector implements RealVector { // ... public static RealVector unmodifiableRealVector(RealVector v) { return new UnmodifiableRealVector(v); } } class UnmodifiableRealVector implements RealVector { // ... } {code} This makes for slightly less cluttered code. Unmodifiable views of RealVector Key: MATH-646 URL: https://issues.apache.org/jira/browse/MATH-646 Project: Commons Math Issue Type: New Feature Affects Versions: 3.0 Reporter: Sébastien Brisard Labels: linear, vector Attachments: MATH-646.patch The issue has been discussed on the [mailing list|http://mail-archives.apache.org/mod_mbox/commons-dev/201108.mbox/CAGRH7HqxUb2y1HmFt9VJ-kxsXwipk_MdO0D=rnuazmgpnot...@mail.gmail.com]. Please find attached a proposal for a new class {{UnmodifiableRealVector}}. I chose not to nest it in {{AbstractRealVector}} because it would make the corresponding file huge. Therefore, {{UnmodifiableRealVector}} is {{final}}. Maybe you'd like it to be {{private}} as well? A static method is provided in {{AbstractRealVector}} to build an {{UnmodifiableRealVector}} from any {{RealVector}}. Tests are also provided. Since iterating through different implementations of {{RealVector}} is actually different, a test is provided for {{UnmodifiableRealVector}} built on {{ArrayRealVector}} and {{OpenMapRealVector}}. These tests both derive from the same abstract test class. Hope everything works fine. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (MATH-646) Unmodifiable views of RealVector
[ https://issues.apache.org/jira/browse/MATH-646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13084913#comment-13084913 ] Gilles commented on MATH-646: - {quote} I chose not to nest it in AbstractRealVector because it would make the corresponding file huge. {quote} Rather than an issue of large source file, the issue is whether this class should part of the public API. Personally I think that it shouldn't because, as discussed on the ML, it is useful from the perspective of the caller (it cannot be modified by the callee) but is not immutable. A method signature containing an UnmodifiableRealVector parameter could be confusing (leading to a false sense of security). I'd prefer it to be a private class defined inside AbstractRealVector.java; the only way to create instances would be by calling the unmodifiableRealVector static method. In UnmodifiableEntry, is it necessary to have a constructor? I'm suspicious that it is possible to call setIndex on the supposedly unmodifiable entry. Maybe that it is harmless (?). In fact, I must admit that the whole Entry hierarchy looks odd to me. Maybe that we should have closer look at [MATH-626]. I have now the impression that moving the sparse vectors into their own hierarchy would simplify a lot of methods... Thanks for the tests; they look quite thorough! A few things in UnmodifiableRealVectorAbstractTest: * The utility method testMethod should probably be named something like doTest or callMethod to avoid confusion (as by convention test... are used for methods called by JUnit). Also, it should be private. * Didn't you forget to write the @Test annotation for testGetSubVector? * I think that it's better to leave the stack trace printing to JUnit (cf. the exceptions generated by the reflection calls): You could just declare those exceptions in the methods signature. * You've excluded ebeDivide from the generic test but it is not handled separately. Unmodifiable views of RealVector Key: MATH-646 URL: https://issues.apache.org/jira/browse/MATH-646 Project: Commons Math Issue Type: New Feature Affects Versions: 3.0 Reporter: Sébastien Brisard Labels: linear, vector Attachments: MATH-646.patch The issue has been discussed on the [mailing list|http://mail-archives.apache.org/mod_mbox/commons-dev/201108.mbox/CAGRH7HqxUb2y1HmFt9VJ-kxsXwipk_MdO0D=rnuazmgpnot...@mail.gmail.com]. Please find attached a proposal for a new class {{UnmodifiableRealVector}}. I chose not to nest it in {{AbstractRealVector}} because it would make the corresponding file huge. Therefore, {{UnmodifiableRealVector}} is {{final}}. Maybe you'd like it to be {{private}} as well? A static method is provided in {{AbstractRealVector}} to build an {{UnmodifiableRealVector}} from any {{RealVector}}. Tests are also provided. Since iterating through different implementations of {{RealVector}} is actually different, a test is provided for {{UnmodifiableRealVector}} built on {{ArrayRealVector}} and {{OpenMapRealVector}}. These tests both derive from the same abstract test class. Hope everything works fine. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira