| 1442 | // |
| 1443 | |
| 1444 | class SVC_Q : public Kernel { |
| 1445 | |
| 1446 | public: |
| 1447 | SVC_Q(const svm_problem& prob, const svm_parameter& param, const schar* y_) |
| 1448 | : Kernel(prob.l, prob.x, param) |
| 1449 | { |
| 1450 | clone(y, y_, prob.l); |
| 1451 | cache = new Cache(prob.l, static_cast<long int>(param.cache_size * (1 << 20))); |
| 1452 | QD = new double[prob.l]; |
| 1453 | |
| 1454 | for (int i = 0; i < prob.l; i++) |
| 1455 | QD[i] = (this->*kernel_function)(i, i); |
| 1456 | } |
| 1457 | |
| 1458 | Qfloat* |
| 1459 | get_Q(int i, int len) const override |
| 1460 | { |
| 1461 | Qfloat* data; |
| 1462 | int start; |
| 1463 | |
| 1464 | if ((start = cache->get_data(i, &data, len)) < len) { |
| 1465 | for (int j = start; j < len; j++) |
| 1466 | data[j] = static_cast<Qfloat>(y[i] * y[j] * (this->*kernel_function)(i, j)); |
| 1467 | } |
| 1468 | |
| 1469 | return data; |
| 1470 | } |
| 1471 | |
| 1472 | double* |
| 1473 | get_QD() const override |
| 1474 | { |
| 1475 | return QD; |
| 1476 | } |
| 1477 | |
| 1478 | void |
| 1479 | swap_index(int i, int j) const override |
| 1480 | { |
| 1481 | cache->swap_index(i, j); |
| 1482 | Kernel::swap_index(i, j); |
| 1483 | swap(y[i], y[j]); |
| 1484 | swap(QD[i], QD[j]); |
| 1485 | } |
| 1486 | |
| 1487 | ~SVC_Q() override |
| 1488 | { |
| 1489 | delete[] y; |
| 1490 | delete cache; |
| 1491 | delete[] QD; |
| 1492 | } |
| 1493 | |
| 1494 | private: |
| 1495 | schar* y; |
| 1496 | Cache* cache; |
| 1497 | double* QD; |
| 1498 | }; |
| 1499 | |
| 1500 | class ONE_CLASS_Q : public Kernel { |
| 1501 |
no outgoing calls
no test coverage detected