Comments (4)
Hi @zibrov-zlobin,
That's awesome! A Kalman filter is one of the use cases I had in mind when I first wrote this library.
Regarding your problem, I seem to recall adding a method to cast a 1x1 matrix into its ElementType. Turns out that was a bad idea so I've since removed in the 2.3 release, can you make sure you're on this version?
Failing that, could you just attach some minimal example code to illustrate the problem?
Thanks!
from basiclinearalgebra.
I am using version 2.3.0.
example code:
BLA::Matrix<2, 2> A = {1, 1, 0, 1};
BLA::Matrix<1, 1> x = {1};
BLA::Matrix<2, 2> res;
Multiply(A, x, res);
results in
kalmanFilter:23: error: no matching function for call to 'Multiply(BLA::Matrix<2, 2>&, BLA::Matrix<1, 1>&, BLA::Matrix<2, 2>&)'
Multiply(A, x, res);
^
/Users/shz/Documents/Arduino/kalmanFilter/kalmanFilter.ino:23:21: note: candidates are:
In file included from /Users/shz/Documents/Arduino/libraries/BasicLinearAlgebra/BasicLinearAlgebra.h:9:0,
from /Users/shz/Documents/Arduino/kalmanFilter/kalmanFilter.ino:1:
/Users/shz/Documents/Arduino/libraries/BasicLinearAlgebra/MemoryDelegate.hpp:47:61: note: template<int rows, int cols, int operandCols, class ElemT, class opElemT, class retElemT> BLA::Matrix<rows, operandCols, BLA::Array<rows, operandCols, retElemT> >& BLA::Multiply(const BLA::Matrix<rows, cols, BLA::Array<rows, cols, opElemT> >&, const BLA::Matrix<cols, operandCols, BLA::Array<cols, operandCols, opElemT> >&, BLA::Matrix<rows, operandCols, BLA::Array<rows, operandCols, retElemT> >&)
Matrix<rows,operandCols,Array<rows,operandCols,retElemT> > &Multiply(const Matrix<rows,cols,Array<rows,cols,ElemT> > &A, const Matrix<cols,operandCols,Array<cols,operandCols,opElemT> > &B, Matrix<rows,operandCols,Array<rows,operandCols,retElemT> > &C)
^
/Users/shz/Documents/Arduino/libraries/BasicLinearAlgebra/MemoryDelegate.hpp:47:61: note: template argument deduction/substitution failed:
/Users/shz/Documents/Arduino/kalmanFilter/kalmanFilter.ino:23:21: note: deduced conflicting values for non-type parameter 'cols' ('2' and '1')
Multiply(A, x, res);
^
In file included from /Users/shz/Documents/Arduino/kalmanFilter/kalmanFilter.ino:1:0:
/Users/shz/Documents/Arduino/libraries/BasicLinearAlgebra/BasicLinearAlgebra.h:312:35: note: template<int rows, int cols, int operandCols, class MemT, class opMemT, class retMemT> BLA::Matrix<rows, operandCols, retMemT>& BLA::Multiply(const BLA::Matrix<rows, cols, opMemT>&, const BLA::Matrix<cols, operandCols, opMemT>&, BLA::Matrix<rows, operandCols, retMemT>&)
Matrix<rows,operandCols,retMemT> &Multiply(const Matrix<rows,cols,MemT> &A, const Matrix<cols,operandCols,opMemT> &B, Matrix<rows,operandCols,retMemT> &C)
^
/Users/shz/Documents/Arduino/libraries/BasicLinearAlgebra/BasicLinearAlgebra.h:312:35: note: template argument deduction/substitution failed:
/Users/shz/Documents/Arduino/kalmanFilter/kalmanFilter.ino:23:21: note: deduced conflicting values for non-type parameter 'cols' ('2' and '1')
Multiply(A, x, res);
^
exit status 1
no matching function for call to 'Multiply(BLA::Matrix<2, 2>&, BLA::Matrix<1, 1>&, BLA::Matrix<2, 2>&)'
thanks!
from basiclinearalgebra.
upd: I think I've tracked down an error in my code that resulted in a situation like the posted above, which at a second thought is somewhat artificial and should not appear.
from basiclinearalgebra.
Ok I see the problem. Basically Multiply
does matrix multiplication so it expects the number of columns of A
to match the number of rows of x
. You might also be familiar with numpy which includes a feature called broadcasting which would do an elementwise multiplication of x
on every element on A
, but unfortunately this library doesn't support that (PRs are welcome though).
In the meantime if you'd like to do an elementwise multiplication on a BLA::Matrix
you can just multiply it by an object of type ElementType
. For example the following should work:
BLA::Matrix<2, 2> A = {1, 1, 0, 1};
BLA::Matrix<1, 1> x = {1};
BLA::Matrix<2, 2> res = A * x(0);
Hope that helps, I'll close this issue but if there's anything else feel free to reopen it.
from basiclinearalgebra.
Related Issues (20)
- Cannot Multiply Two Matrices with nondefault type of double HOT 2
- Tabbed Function is not Working With the BLA HOT 2
- Something weird is happening when I want to display the Matrix data HOT 2
- Access specific row/col? HOT 1
- Library using too much memory when used in classes? HOT 2
- examples don't compile HOT 2
- Matrix Multiplication with different sized matrices gives errors HOT 2
- After the latest update, I'm getting two template-related compilation errors HOT 3
- BLA not compiling for esp32 core boards. HOT 2
- Invert appears to return improper results when using a double Array HOT 1
- issue with matrix inversion HOT 4
- Initialize Matrix to 0 HOT 2
- Initialize matrix with random values HOT 4
- Custom matrix diagonal values HOT 1
- Delete a matrix instace HOT 1
- Inverse Matrix 3x3 false HOT 2
- Sparse matrix HOT 2
- A 3D pose representation to work with the basicLinearAlgebra library HOT 3
- Implementing a "ones" matrix
- numerically differentiating vector valued functions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from basiclinearalgebra.