How To Find determinant of a metrix using c#???
How to find determinant of a metrix using C #.Please give me the complete coding in C# to find determinant of a metrix.i want to do this problem in console application..expecting reply thank you
How To Find determinant of a metrix using c#???
How to find determinant of a metrix using C #.Please give me the complete coding in C# to find determinant of a metrix.i want to do this problem in console application..expecting reply thank you
At the top of the forum it says:
" Also, to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well."
So put some effort into it first.
At the top of the forum it says:
" Also, to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well."
So put some effort into it first.
I tried alot for this ..After that only i started this thread..i want to do this problem with out using function..please help me
So what have you tried for yourself?
Even if the code you tried seems ridiculous and bad,don't mind. Send it, it shows us you have done some effort. :)
Hi Manswab
Enjoy!!!! My code works on gauss elimination method.....Try using recursion function to solve by Cramer's method, that is more simple
private void GElimination(ref float[,] A, ref float[] B, ref float[] re, int cb) {
// ----Check For Uncertainity :)
if (((WA2dt.Mem.Count - 1)
<= 0)) {
return;
}
float Triangular_A;
float line_1;
float temporary_1;
float multiplier_1;
float sum_1;
float[,] soln;
for (n = 0; (n <= cb); n++) {
for (m = 0; (m <= cb); m++) {
Triangular_A[m, n] = A(m, n);
}
}
// .... substituting the force to triangularmatrics....
for (n = 0; (n <= cb); n++) {
Triangular_A[n, (cb + 1)] = B(n);
}
// ...............soving the triangular matrics.............
for (k = 0; (k <= cb); k++) {
// ......Bring a non-zero element first by changes lines if necessary
if ((Triangular_A[k, k] == 0)) {
for (n = k; (n <= cb); n++) {
if ((Triangular_A[n, k] != 0)) {
line_1 = n;
}
break;
// Finds line_1 with non-zero element
}
// ..........Change line k with line_1
for (m = k; (m <= cb); m++) {
temporary_1 = Triangular_A[k, m];
Triangular_A[k, m] = Triangular_A[line_1, m];
Triangular_A[line_1, m] = temporary_1;
}
}
// ....For other lines, make a zero element by using:
// .........Ai1=Aij-A11*(Aij/A11)
// .....and change all the line using the same formula for other elements
for (n = (k + 1); (n <= cb); n++) {
if ((Triangular_A[n, k] != 0)) {
// if it is zero, stays as it is
multiplier_1 = (Triangular_A[n, k] / Triangular_A[k, k]);
for (m = k; (m
<= (cb + 1)); m++) {
Triangular_A[n, m] = (Triangular_A[n, m]
- (Triangular_A[k, m] * multiplier_1));
}
}
}
}
// ..... calculating the dof value..........
// First, calculate last xi (for i = System_DIM)
soln[(cb + 1)] = (Triangular_A[cb, (cb + 1)] / Triangular_A[cb, cb]);
// ................
for (n = 1; (n <= cb); n++) {
sum_1 = 0;
for (m = 1; (m <= n); m++) {
sum_1 = (sum_1
+ (soln[(cb + (2 - m))] * Triangular_A[(cb - n), (cb + (1 - m))]));
}
soln[(cb + (1 - n))] = ((Triangular_A[(cb - n), (cb + 1)] - sum_1)
/ Triangular_A[(cb - n), (cb - n)]);
}
for (n = 0; (n <= cb); n++) {
re(n) = soln[(n + 1)];
}
Rgrds
Sam
Hey manswab
I forgot, the above is for solving eqns
Ax = B
All u have to do is when the above code completes eliminating like below
|A1 A2 A3.....An|
|0 B2 B3 ..... Bn|
|0 0 C3 ..... Cn|
|..................|
|0 0 0 0 Yn-1 Yn|
|0 0 0 0 0 0 Zn|
Use diagonal multiplication from A1 till end for the determinant of the triangular matrix.
So you got some work to do before using the above code.
Rgrds
Sam
Thanks for your replyy
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.