Opened 4 years ago

Closed 3 years ago

#836 closed request (fixed)

allow operator*(const Matrix&, const Matrix&)

Reported by: Peter Owned by: Peter
Priority: major Milestone: yat 0.15
Component: utility Version:
Keywords: Cc:

Description (last modified by Peter)

Needs ticket #474 Related to ticket #835

The API does not allow code like Matrix C = A * B mainly because it would need to return by value, which is slow, and it is better to use

Matrix C(A);
C *= B;

This argument does not really hold strong, once move constructors have been implemented for class Matrix (see #474), because then, IIUC, the return from

operator*(const Matrix&, const Matrix&);

is light as a feather. and likewise the construction from the temp Matrix is also ultra lightweight.

Change History (7)

comment:1 Changed 3 years ago by Peter

Description: modified (diff)

comment:2 Changed 3 years ago by Peter

Milestone: yat 0.x+yat 0.15
Owner: changed from Jari Häkkinen to Peter
Type: discussionrequest

The idea here is that operator*(const Matrix& lhs, const Matrix& rhs) does not return a Matrix. Instead it returns a Proxy class, which holds a gsl_matrix* that is calculated just like blas_result_ in operator*=. Then if we provide assignment from Proxy&& to Matrix we have multiplication that is as fast as operator*=.

Having done this, we can generalize - using templates - to more complex expressions (such as A + B * C).

comment:3 Changed 3 years ago by Peter

Status: newassigned

comment:4 Changed 3 years ago by Peter

(In [3603]) tests for matrix expressions. refs #836

comment:5 Changed 3 years ago by Peter

(In [3604]) fix typos. refs #836

comment:6 Changed 3 years ago by Peter

(In [3605]) A first go at implementing template expression in order to provide fast linalg operators with a intuitive interface.

Currently these operators are implemented (far from a complete set) Vector + Vector Vector - Vector Vector * Vector Scalar * Vector Vector * Scalar Matrix * Vector Vector * Matrix Matrix + Matrix Matrix - Matrix Matrix * Matrix Scalar * Matrix Matrix * Scalar

refs #836

comment:7 Changed 3 years ago by Peter

Resolution: fixed
Status: assignedclosed

Matrix*Matrix is now implemented. I close this ticket and leave additions to the interface in other tickets.

Note: See TracTickets for help on using tickets.