You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ole Ersoy <ol...@gmail.com> on 2015/12/16 20:08:03 UTC
[math] AbstractFieldMatrix.checkMultiplicationCompatible() throws
exception?
Hi,
I'm working on making the linear package standalone. The methods that perform precondition checks for matrix operations throw exceptions (See below). An option would be return a boolean instead. Obviously I would love it if CM adopts the code at some point, so I want to check whether changing the interface is going to kill kittens.
Cheers,
- Ole
CURRENT
/**
* Check if a matrix is multiplication compatible with the instance.
*
* @param m
* Matrix to check.
* @throws DimensionMismatchException
* if the matrix is not multiplication-compatible with instance.
*/
protected void checkMultiplicationCompatible(final FieldMatrix<T> m) throws DimensionMismatchException {
if (getColumnDimension() != m.getRowDimension()) {
throw new DimensionMismatchException(m.getRowDimension(), getColumnDimension());
}
}
PROPOSED
/**
* Check if a matrix is multiplication compatible with the instance.
*
* @param m
* Matrix to check.
* @return true if the matrix is multiplication compatible, false otherwise.
*/
protected boolean checkMultiplicationCompatible(final FieldMatrix<T> m) {
if (getColumnDimension() != m.getRowDimension()) {
return false;
}
return true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [math] AbstractFieldMatrix.checkMultiplicationCompatible() throws
exception?
Posted by Ole Ersoy <ol...@gmail.com>.
Actually I think I see why bubbling exceptions is better than performing boolean checks...so just ignore, unless there is some merit to it...
Cheers,
Ole
On 12/16/2015 01:08 PM, Ole Ersoy wrote:
> Hi,
>
> I'm working on making the linear package standalone. The methods that perform precondition checks for matrix operations throw exceptions (See below). An option would be return a boolean instead. Obviously I would love it if CM adopts the code at some point, so I want to check whether changing the interface is going to kill kittens.
>
> Cheers,
> - Ole
>
> CURRENT
> /**
> * Check if a matrix is multiplication compatible with the instance.
> *
> * @param m
> * Matrix to check.
> * @throws DimensionMismatchException
> * if the matrix is not multiplication-compatible with instance.
> */
> protected void checkMultiplicationCompatible(final FieldMatrix<T> m) throws DimensionMismatchException {
> if (getColumnDimension() != m.getRowDimension()) {
> throw new DimensionMismatchException(m.getRowDimension(), getColumnDimension());
> }
> }
>
> PROPOSED
>
> /**
> * Check if a matrix is multiplication compatible with the instance.
> *
> * @param m
> * Matrix to check.
> * @return true if the matrix is multiplication compatible, false otherwise.
> */
> protected boolean checkMultiplicationCompatible(final FieldMatrix<T> m) {
> if (getColumnDimension() != m.getRowDimension()) {
> return false;
> }
> return true;
> }
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org