RBF用OLS训练权值的代码 求解释代码!!!
public void QR_Algorithm(List<double> temp_result, List<List<double>> Amatrix, List<double> Bmatrix, int MatrixRow, int MatrixColumn){
int k = 0, l = 1; //序号k以下的元素,才做处理,l表处理的cloumn,s为序号k以下(包含)到最後元素的平方和开根号
int i, j;
bool CheckIf = true;
double s, temp_s = 0.0;
double r, temp_r = 0.0;
List<double> DiagonalofRMatrix = new List<double>(); //double *DiagonalofRMatrix;
//DiagonalofRMatrix存放R榘阵的对角线值
DiagonalofRMatrix = CMatrix.Vector(MatrixColumn+1, 0.0);
while (l <= MatrixColumn && CheckIf == true) // MatrixColumn隐藏神经元
{
k = k + 1;
if (k == MatrixRow) //MatrixRow样本数
{
DiagonalofRMatrix[l] = Amatrix[k][l]; //Amatrix[k][l]表示样本k在隐藏神经元l中的高斯函数值
CheckIf = false;
continue; //跳出整个l回圈
}
temp_s = 0.0; //temp_s要归零
for (i = k; i <= MatrixRow; i++)
temp_s = temp_s + Amatrix[i][l] *Amatrix[i][l]; //所有样本对隐藏神经元的高斯函数值的平方
//temp_s存放元素平方和
s = Math.Sqrt(temp_s);
if (s == 0.0)
{
DiagonalofRMatrix[l] = 0.0;
continue; //跳至下个l
}
double t = Amatrix[k][l];
if (t >= 0) //t与s要异号
{
temp_r = s * (s + t);
r = 1 / Math.Sqrt(temp_r);
}
else
{
temp_r = -s * (-s + (-t));
r = 1 / Math.Sqrt(temp_r);
}
DiagonalofRMatrix[l] = -s;
Amatrix[k][k] = r * (s + t);
for (i = k + 1; i <= MatrixRow; i++)
{
Amatrix[i][k] = r * Amatrix[i][l];
}
for (j = l + 1; j <= MatrixColumn; j++)
{
t = 0;
for (i = k; i <= MatrixRow; i++)
t = t + Amatrix[i][k] * Amatrix[i][j];
for (i = k; i <= MatrixRow; i++)
Amatrix[i][j] = Amatrix[i][j] - t * Amatrix[i][k];
}
l++;
}
QR_leastsquare(temp_result, Amatrix, Bmatrix, DiagonalofRMatrix, MatrixRow, MatrixColumn);
CMatrix.FreeVector(DiagonalofRMatrix);
}
主要是while中怎么具体实现正交矩阵的