TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed sami
NA
64
200.7k
Can anyone explain that c# code, please ?
Mar 1 2013 2:10 PM
double[] msolve(double[][] m)
{
int i, j, k;
int n = m.Length;
double factor = 0;
double precision = 1e9;
double[] m1 = new double[n];
double[][] m2 = new double[n][];
for (i = 0; i < n; i++)
{
m2[i] = new double[m[i].Length];
for (j = 0; j < m[i].Length; j++)
{
m2[i][j] = m[i][j];
}
}
for (k = 1; k < n; k++) for (i = k; i < n; i++)
{
factor = m2[i][k - 1] / m2[k - 1][k - 1];
for (j = 0; j <= n; j++) m2[i][j] -= m2[k - 1][j] * factor;
}
for (i = n - 1; i >= 0; i--)
{
m1[i] = m2[i][n];
for (j = n - 1; j > i; j--) m1[i] -= m2[i][j] * m1[j];
m1[i] /= m2[i][i];
m1[i] = Math.Round(m1[i] * precision) / precision;
}
return m1;//matrix(n, 1, m1);
}
private void button1_Click(object sender, EventArgs e)
{
var d = new double[][] { new double[] { 1,1,2,8}, new double[] { -1,-2,3,1},new double []{3,-7,4,10}};
var sl = msolve(d);
}
Reply
Answers (
1
)
unable to get percentage in decimal values ?
C# Console.ReadLine error