Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void ProcedureGrammaShmita(ref Vector<double> lambda, ref Matrix<double> d)
- {
- List<Vector<double>> a = new List<Vector<double>>();
- List<Vector<double>> b = new List<Vector<double>>();
- for (int i = 0; i < n + 1; i++)
- {
- if (lambda[i].Equals(0))
- {
- a.Add(d.Row(i));
- }
- else
- {
- Vector<double> temp = Vector<double>.Build.Dense(n + 1, 0.0);
- for (int j = i; j < n + 1; j++)
- {
- temp = temp.Add(d.Row(j).Multiply(lambda[j]));
- }
- a.Add(temp);
- }
- }
- for (int i = 0; i < n + 1; i++)
- {
- if (i != 0)
- {
- Vector<double> temp = Vector<double>.Build.Sparse(n + 1);
- for (int j = 0; j < i; j++)
- {
- temp = temp.Add(d.Row(j).Multiply(a[i].ConjugateDotProduct(d.Row(j))));
- }
- temp = a[i].Subtract(temp);
- b.Add(temp);
- }
- else
- {
- b.Add(a[i]);
- }
- d.SetRow(i,b[i].Divide(b[i].L2Norm()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement