145 SIZE_CHECK(batchX1.size2() == batchX2.size2());
148 std::size_t sizeX1 = batchX1.size1();
149 std::size_t sizeX2 = batchX2.size1();
151 ensure_size(result,sizeX1,sizeX2);
153 for(std::size_t i = 0; i != sizeX1; ++i){
154 for(std::size_t j = 0; j != sizeX2; ++j){
155 double dmnorm2 = diagonalMahalanobisDistanceSqr(row(batchX1,i), row(batchX2,j),
m_gammas);
156 result(i,j)=std::exp(-dmnorm2);
166 SIZE_CHECK(batchX1.size2() == batchX2.size2());
169 std::size_t sizeX1 = batchX1.size1();
170 std::size_t sizeX2 = batchX2.size1();
172 InternalState& s = state.
toState<InternalState>();
173 s.resize(sizeX1,sizeX2);
175 ensure_size(result,sizeX1,sizeX2);
177 for(std::size_t i = 0; i != sizeX1; ++i){
178 for(std::size_t j = 0; j != sizeX2; ++j){
179 double dmnorm2 = diagonalMahalanobisDistanceSqr(row(batchX1,i), row(batchX2,j),
m_gammas);
180 result(i,j) = std::exp(-dmnorm2);
181 s.kxy(i,j) = result(i,j);
195 RealMatrix
const& coefficients,
199 SIZE_CHECK(batchX1.size2() == batchX2.size2());
202 std::size_t sizeX1 = batchX1.size1();
203 std::size_t sizeX2 = batchX2.size1();
207 InternalState
const& s = state.
toState<InternalState>();
209 for(std::size_t i = 0; i != sizeX1; ++i){
210 for(std::size_t j = 0; j != sizeX2; ++j){
211 double coeff = coefficients(i,j) * s.kxy(i,j);
212 gradient -= coeff *
m_gammas *
sqr(row(batchX1,i)-row(batchX2,j));
224 RealMatrix
const& coefficientsX2,
228 SIZE_CHECK(batchX1.size2() == batchX2.size2());
231 std::size_t sizeX1 = batchX1.size1();
232 std::size_t sizeX2 = batchX2.size1();
234 InternalState
const& s = state.
toState<InternalState>();
238 for(std::size_t i = 0; i != sizeX1; ++i){
239 for(std::size_t j = 0; j != sizeX2; ++j){
240 double coeff = coefficientsX2(i,j) * s.kxy(i,j);
241 row(gradient,i) += coeff *
m_gammas * (row(batchX1,i)-row(batchX2,j));