You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gilles Sadowski <gi...@harfang.homelinux.org> on 2011/09/02 19:07:47 UTC
Re: svn commit: r1164615 -
/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
Hi Sébastien.
>
> /**
> * Gauss-Newton least-squares solver.
> @@ -146,8 +148,13 @@ public class GaussNewtonOptimizer extend
> DecompositionSolver solver = useLU ?
> new LUDecompositionImpl(mA).getSolver() :
> new QRDecompositionImpl(mA).getSolver();
> - final double[] dX = solver.solve(b);
> -
> + final RealVector dummy = solver.solve(new ArrayRealVector(b, false));
> + final double[] dX;
> + if (dummy instanceof ArrayRealVector){
> + dX = ((ArrayRealVector) dummy).getDataRef();
> + }else{
> + dX = dummy.getData();
> + }
In my opinion, the hypothetical efficiency gain is not worth the convoluted
code so:
---
final double[] dX = solver.solve(new ArrayRealVector(b, false)).toArray();
---
Also, next time, when you'll really need a curly bracket ;-), please insert
a space character before it, and around keywords too:
---
if (ok) {
// ...
} else {
// ...
}
---
Sorry to be picky and thank you,
Gilles
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1164615 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
Posted by Sébastien Brisard <se...@m4x.org>.
Excellent! Thanks a lot, Luc.
I hope I will never bother you again with formatting...
Sébastien
2011/9/2 Luc Maisonobe <Lu...@free.fr>:
> Le 02/09/2011 20:14, Sébastien Brisard a écrit :
>>
>> Sorry about code formatting. Which IDE are you using? If you (or
>> anyone else) are using Eclipse, could you share the configuration of
>> your code formatter with me? Or any external formatter indeed? My
>> configuration doesn't comply with your requirements regarding
>> indentation, therefore I don't use it with CM, hence the formatting
>> errors you've detected. I'll do my best in the future.
>
> You can use this one:
> <http://people.apache.org/~luc/Apache-commons.xml>.
>
> Luc
>
>> Sébastien
>>
>> 2011/9/2 Gilles Sadowski<gi...@harfang.homelinux.org>:
>>>
>>> Hi Sébastien.
>>>
>>>>
>>>> /**
>>>> * Gauss-Newton least-squares solver.
>>>> @@ -146,8 +148,13 @@ public class GaussNewtonOptimizer extend
>>>> DecompositionSolver solver = useLU ?
>>>> new LUDecompositionImpl(mA).getSolver() :
>>>> new QRDecompositionImpl(mA).getSolver();
>>>> - final double[] dX = solver.solve(b);
>>>> -
>>>> + final RealVector dummy = solver.solve(new
>>>> ArrayRealVector(b, false));
>>>> + final double[] dX;
>>>> + if (dummy instanceof ArrayRealVector){
>>>> + dX = ((ArrayRealVector) dummy).getDataRef();
>>>> + }else{
>>>> + dX = dummy.getData();
>>>> + }
>>>
>>> In my opinion, the hypothetical efficiency gain is not worth the
>>> convoluted
>>> code so:
>>> ---
>>> final double[] dX = solver.solve(new ArrayRealVector(b,
>>> false)).toArray();
>>> ---
>>>
>>> Also, next time, when you'll really need a curly bracket ;-), please
>>> insert
>>> a space character before it, and around keywords too:
>>> ---
>>> if (ok) {
>>> // ...
>>> } else {
>>> // ...
>>> }
>>> ---
>>>
>>> Sorry to be picky and thank you,
>>> Gilles
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1164615 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
Posted by Luc Maisonobe <Lu...@free.fr>.
Le 02/09/2011 20:14, Sébastien Brisard a écrit :
> Sorry about code formatting. Which IDE are you using? If you (or
> anyone else) are using Eclipse, could you share the configuration of
> your code formatter with me? Or any external formatter indeed? My
> configuration doesn't comply with your requirements regarding
> indentation, therefore I don't use it with CM, hence the formatting
> errors you've detected. I'll do my best in the future.
You can use this one:
<http://people.apache.org/~luc/Apache-commons.xml>.
Luc
> Sébastien
>
> 2011/9/2 Gilles Sadowski<gi...@harfang.homelinux.org>:
>> Hi Sébastien.
>>
>>>
>>> /**
>>> * Gauss-Newton least-squares solver.
>>> @@ -146,8 +148,13 @@ public class GaussNewtonOptimizer extend
>>> DecompositionSolver solver = useLU ?
>>> new LUDecompositionImpl(mA).getSolver() :
>>> new QRDecompositionImpl(mA).getSolver();
>>> - final double[] dX = solver.solve(b);
>>> -
>>> + final RealVector dummy = solver.solve(new ArrayRealVector(b, false));
>>> + final double[] dX;
>>> + if (dummy instanceof ArrayRealVector){
>>> + dX = ((ArrayRealVector) dummy).getDataRef();
>>> + }else{
>>> + dX = dummy.getData();
>>> + }
>>
>> In my opinion, the hypothetical efficiency gain is not worth the convoluted
>> code so:
>> ---
>> final double[] dX = solver.solve(new ArrayRealVector(b, false)).toArray();
>> ---
>>
>> Also, next time, when you'll really need a curly bracket ;-), please insert
>> a space character before it, and around keywords too:
>> ---
>> if (ok) {
>> // ...
>> } else {
>> // ...
>> }
>> ---
>>
>> Sorry to be picky and thank you,
>> Gilles
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1164615 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
Posted by Sébastien Brisard <se...@m4x.org>.
Sorry about code formatting. Which IDE are you using? If you (or
anyone else) are using Eclipse, could you share the configuration of
your code formatter with me? Or any external formatter indeed? My
configuration doesn't comply with your requirements regarding
indentation, therefore I don't use it with CM, hence the formatting
errors you've detected. I'll do my best in the future.
Sébastien
2011/9/2 Gilles Sadowski <gi...@harfang.homelinux.org>:
> Hi Sébastien.
>
>>
>> /**
>> * Gauss-Newton least-squares solver.
>> @@ -146,8 +148,13 @@ public class GaussNewtonOptimizer extend
>> DecompositionSolver solver = useLU ?
>> new LUDecompositionImpl(mA).getSolver() :
>> new QRDecompositionImpl(mA).getSolver();
>> - final double[] dX = solver.solve(b);
>> -
>> + final RealVector dummy = solver.solve(new ArrayRealVector(b, false));
>> + final double[] dX;
>> + if (dummy instanceof ArrayRealVector){
>> + dX = ((ArrayRealVector) dummy).getDataRef();
>> + }else{
>> + dX = dummy.getData();
>> + }
>
> In my opinion, the hypothetical efficiency gain is not worth the convoluted
> code so:
> ---
> final double[] dX = solver.solve(new ArrayRealVector(b, false)).toArray();
> ---
>
> Also, next time, when you'll really need a curly bracket ;-), please insert
> a space character before it, and around keywords too:
> ---
> if (ok) {
> // ...
> } else {
> // ...
> }
> ---
>
> Sorry to be picky and thank you,
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org