126 SHARK_ASSERT(std::abs((
unsigned int)newParameters(0) - newParameters(0)) <= 2*std::numeric_limits<double>::epsilon());
128 m_degree = (
unsigned int)newParameters(0);
130 m_offset = std::exp(newParameters(1));
138 m_offset = std::exp(newParameters(0));
168 SIZE_CHECK(batchX1.size2() == batchX2.size2());
169 std::size_t sizeX1 = batchX1.size1();
170 std::size_t sizeX2 = batchX2.size1();
171 result.resize(sizeX1,sizeX2);
174 noalias(result) = prod(batchX1,trans(batchX2));
178 noalias(result) = pow(result,
m_degree);
182 SIZE_CHECK(batchX1.size2() == batchX2.size2());
184 std::size_t sizeX1 = batchX1.size1();
185 std::size_t sizeX2 = batchX2.size1();
187 InternalState& s = state.
toState<InternalState>();
188 s.resize(sizeX1,sizeX2);
189 result.resize(sizeX1,sizeX2);
192 noalias(s.base) = prod(batchX1,trans(batchX2));
197 noalias(result) = pow(s.base,
m_degree);
199 noalias(result) = s.base;
200 noalias(s.exponentedProd) = result;
208 RealMatrix
const& coefficients,
213 std::size_t sizeX1 = batchX1.size1();
214 std::size_t sizeX2 = batchX2.size1();
216 InternalState
const& s = state.
toState<InternalState>();
219 SIZE_CHECK(batchX1.size2() == batchX2.size2());
222 SIZE_CHECK(s.exponentedProd.size1() == sizeX1);
223 SIZE_CHECK(s.exponentedProd.size2() == sizeX2);
228 gradient(0) = sum(coefficients);
234 gradient(0) =
m_degree * sum(safe_div(s.exponentedProd,s.base,0.0) * coefficients);
245 RealMatrix
const& coefficientsX2,
250 std::size_t sizeX1 = batchX1.size1();
251 std::size_t sizeX2 = batchX2.size1();
252 gradient.resize(sizeX1,batchX1.size2());
254 InternalState
const& s = state.
toState<InternalState>();
257 SIZE_CHECK(batchX1.size2() == batchX2.size2());
260 SIZE_CHECK(s.exponentedProd.size1() == sizeX1);
261 SIZE_CHECK(s.exponentedProd.size2() == sizeX2);
269 noalias(gradient) = prod(coefficientsX2,batchX2);
275 RealMatrix weights = coefficientsX2 * safe_div(s.exponentedProd,s.base,0.0);
279 noalias(gradient) =
m_degree * prod(weights,batchX2);