Comments (8)
Hi @abhishekkranjan, this is not the place to post such question :-). Try a forum instead 👍
am really sorry for posting that question, I was unaware of it.
from ublas.
Hi @abhishekkranjan, this is not the place to post such question :-). Try a forum instead +1
yes. we can discuss it either directly in gitter: https://gitter.im/boostorg/ublas
or use the mailing list: [email protected]
thanks, i have joined the gitter room
from ublas.
Hi Richel,
How does your algorithm compare in speed and stability vs (e.g.) Householder QR decomposition? https://en.m.wikipedia.org/wiki/QR_decomposition#Connection_to_a_determinant_or_a_product_of_eigenvalues
All the best, Paul
On 18 April 2016 7:41:16 PM AEST, Richel Bilderbeek [email protected] wrote:
Boost.uBLAS can calculate the determinant of (at most) 2x2 matrices. I
have a piece of code that can do this for any matrix size (which is
http://www.richelbilderbeek.nl/CppUblasMatrixExample7.htm), that
already has been tested.If accepted, I volunteer to try to add this to Boost, but I'd need some
help to up the quality even more.Is this already been done? If no, would it be appreciated if I (create
and) submit a Pull Request?
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#38
Paul Leopardi - http://sites.google.com/site/paulleopardi/
from ublas.
Undo: AFAIK I do not use Householder QR decomposition. I cannot remember the algorithm name I used. I do remember it was something using 2x2 matrices as a building block for bigger ones.
from ublas.
I have been using this algorithm in my research and has given me no problems for inverting 10x10 matrices coming from a spacial least-squares polynomial fitting problem. It seems reasonably fast, although I've only used it in small systems (about 25 times per node, for about 2500 nodes).
Well done, Richel.
from ublas.
Am not getting pr, can you please help how can i contribute my code to calculate the determinant of any matrix.
//My cpp code
// C++ program to find Deteminant of a matrix
#include <bits/stdc++.h>
using namespace std;
// Dimension of input square matrix
#define N 4
// Function to get determinant of matrix
int determinantOfMatrix(int mat[N][N], int n)
{
int num1, num2, det = 1, index,
total = 1; // Initialize result
// temporary array for storing row
int temp[n + 1];
// loop for traversing the diagonal elements
for (int i = 0; i < n; i++)
{
index = i; // initialize the index
// finding the index which has non zero value
while (mat[index][i] == 0 && index < n)
{
index++;
}
if (index == n) // if there is non zero element
{
// the determinat of matrix as zero
continue;
}
if (index != i)
{
// loop for swaping the diagonal element row and
// index row
for (int j = 0; j < n; j++)
{
swap(mat[index][j], mat[i][j]);
}
// determinant sign changes when we shift rows
// go through determinant properties
det = det * pow(-1, index - i);
}
// storing the values of diagonal row elements
for (int j = 0; j < n; j++)
{
temp[j] = mat[i][j];
}
// traversing every row below the diagonal element
for (int j = i + 1; j < n; j++)
{
num1 = temp[i]; // value of diagonal element
num2 = mat[j][i]; // value of next row element
// traversing every column of row
// and multiplying to every row
for (int k = 0; k < n; k++)
{
// multiplying to make the diagonal
// element and next row element equal
mat[j][k]
= (num1 * mat[j][k]) - (num2 * temp[k]);
}
total = total * num1; // Det(kA)=kDet(A);
}
}
// mulitplying the diagonal elements to get determinant
for (int i = 0; i < n; i++)
{
det = det * mat[i][i];
}
return (det / total); // Det(kA)/k=Det(A);
}
// Driver code
int main()
{
/*int mat[N][N] = {{6, 1, 1},
{4, -2, 5},
{2, 8, 7}}; */
int mat[N][N] = { { 1, 0, 2, -1 },
{ 3, 0, 0, 5 },
{ 2, 1, 4, -3 },
{ 1, 0, 5, 0 } };
// Function call
printf("Determinant of the matrix is : %d",
determinantOfMatrix(mat, N));
return 0;
}
from ublas.
Hi @abhishekkranjan, this is not the place to post such question :-). Try a forum instead 👍
from ublas.
Hi @abhishekkranjan, this is not the place to post such question :-). Try a forum instead +1
yes. we can discuss it either directly in gitter: https://gitter.im/boostorg/ublas
or use the mailing list: [email protected]
from ublas.
Related Issues (20)
- Wrong `to_strides_v` computation
- Transpose for Rank One Tensors HOT 1
- Exception Raised for Static Rank Tensor inside the Tensor Times Tensor Product
- Use of Template Type in the Wrong Place HOT 4
- Extension of lifetime within tensor expression templates for prvalues not guaranteed. HOT 1
- Incorrect parameter ordering in element_sub HOT 4
- Error in Github Actions due to incorrect msvc toolset version
- Compiler cannot perform small-object and other optimizations in algorithms.cpp HOT 5
- Use function call operator for indexing instead of at HOT 2
- Fixing iteration-type of for-loop. HOT 3
- Wrong implementation of copy constructor for the different type of layout
- Tensor examples in the documentation are not correct.
- Boost\libs\numeric\ublas failed to build due to error C2059, C2065, C2923, C2976, C2447 .... on MSVC HOT 6
- Deprecated Inheritance From std::iterator Didn't Make It To Release HOT 7
- ublas::matrix broken with compiler error with build 1.80 but not 1.63 HOT 2
- ublas::matrix::resize with preserve= true, can it be implemented without temporary storage?
- No type named ''allocator_size_type“ in namespace 'boost' HOT 1
- Modular Boost C++ Libraries Request HOT 1
- Wrong behavior of map_array copy constructor.
- Broken interaction between std::vector and ublas::c_vector
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 ublas.