00001 /******************************************************************************
00002
00003 Copyright 2008 Departamento de Realidad Virtual
00004 y Unidad de Cómputo Aplicado DGSGA, UNAM.
00005
00006
00007 This file is part of RBF++.
00008
00009 RBF++ is free software: you can redistribute it and/or modify
00010 it under the terms of the GNU General Public License as published by
00011 the Free Software Foundation, either version 3 of the License, or
00012 (at your option) any later version.
00013
00014 RBF++ is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 GNU General Public License for more details.
00018
00019 You should have received a copy of the GNU General Public License
00020 along with RBF++. If not, see <http://www.gnu.org/licenses/>.
00021
00022
00023 *******************************************************************************/
00024
00025 /*
00026 Author: Daniel Cervantes Cabrera.
00027 Project: RBF++
00028 Institution: DGSCA, UNAM.
00029 Date: 3/05/08
00030 Description: Gramm matrix class
00031 */
00032
00033
00034 #include <RBF/GrammMatrix.h>
00035 #include <LA/Matrix.h>
00036
00037 namespace RBF{
00038
00039 template<typename T>
00040 GrammMatrix<T>::GrammMatrix(LA::Matrix<T> &M, LA::Matrix<T> &P)
00041 {
00042 dimension = M.getCol() + P.getCol();
00043 this -> resize(dimension, dimension);
00044
00045 int N = M.getRow();
00046
00047 for(int i = 0; i < N; ++i)
00048 for(int j = 0; j < N; ++j)
00049 this->data[i][j] = M(i, j);
00050
00051 for(int i = 0; i < N; ++i)
00052 for(int j = N; j < dimension; ++j)
00053 this->data[i][j] = P(i, j - N);
00054
00055 LA::Matrix<T> PT = P.transpose();
00056
00057 for(int i = N; i < dimension; ++i)
00058 for(int j = 0; j < N; ++j)
00059 this->data[i][j] = PT(i - N, j);
00060 }
00061
00063
00076 template<typename T>
00077 GrammMatrix<T>::GrammMatrix(LA::Matrix<T> &WL, LA::Matrix<T> &PL, LA::Matrix<T> &WB, LA::Matrix<T> &PB, LA::Matrix<T> &PT) {
00078
00079 int NI = WL.getRow(), NF = WB.getRow();
00080 int N = NI + NF;
00081 int NC = PL.getCol();
00082
00083 dimension = N + NC;
00084
00085 this->resize(dimension, dimension);
00086
00087 for(int i = 0; i < NI; ++i)
00088 for(int j = 0; j < N; ++j)
00089 this->data[i][j] = WL(i, j);
00090
00091 for(int i = 0; i < NI; ++i)
00092 for(int j = N; j < dimension; ++j)
00093 this->data[i][j] = PL(i, j - N);
00094
00095 for(int i = NI; i < N ; ++i)
00096 for(int j = 0; j < N; ++j)
00097 this->data[i][j] = WB(i - NI, j);
00098
00099 for(int i = NI; i < N ; ++i)
00100 for(int j = N; j < dimension; ++j)
00101 this->data[i][j] = PB(i - NI, j - N);
00102
00103 for(int i = N; i < dimension ; ++i)
00104 for(int j = 0; j < N; ++j)
00105 this->data[i][j] = PT(i-N,j);
00106
00107 for(int i=0; i< NC; ++i)
00108 for(int j = 0; j < NC; ++j)
00109 this->data[N+i][N+j] = 0.0;
00110
00111 }
00112 };
Superior

Tenemos 23 visitantes y ningun miembro en Línea