| 452 | } |
| 453 | |
| 454 | distance_function operator- ( |
| 455 | const distance_function& rhs |
| 456 | ) const |
| 457 | { |
| 458 | // make sure requires clause is not broken |
| 459 | DLIB_ASSERT(get_kernel() == rhs.get_kernel(), |
| 460 | "\t distance_function distance_function::operator-()" |
| 461 | << "\n\t You can only subtract two distance_functions if they use the same kernel." |
| 462 | ); |
| 463 | |
| 464 | if (alpha.size() == 0 && rhs.alpha.size() == 0) |
| 465 | return distance_function(kernel_function); |
| 466 | else if (alpha.size() != 0 && rhs.alpha.size() == 0) |
| 467 | return *this; |
| 468 | else if (alpha.size() == 0 && rhs.alpha.size() != 0) |
| 469 | return -1*rhs; |
| 470 | else |
| 471 | return distance_function(join_cols(alpha, -rhs.alpha), |
| 472 | b + rhs.b - 2*trans(alpha)*kernel_matrix(kernel_function,basis_vectors,rhs.basis_vectors)*rhs.alpha, |
| 473 | kernel_function, |
| 474 | join_cols(basis_vectors, rhs.basis_vectors)); |
| 475 | } |
| 476 | |
| 477 | private: |
| 478 |
nothing calls this directly
no test coverage detected