| 1498 | }; |
| 1499 | |
| 1500 | class ONE_CLASS_Q : public Kernel { |
| 1501 | |
| 1502 | public: |
| 1503 | ONE_CLASS_Q(const svm_problem& prob, const svm_parameter& param) |
| 1504 | : Kernel(prob.l, prob.x, param) |
| 1505 | { |
| 1506 | cache = new Cache(prob.l, static_cast<long int>(param.cache_size * (1 << 20))); |
| 1507 | QD = new double[prob.l]; |
| 1508 | |
| 1509 | for (int i = 0; i < prob.l; i++) |
| 1510 | QD[i] = (this->*kernel_function)(i, i); |
| 1511 | } |
| 1512 | |
| 1513 | Qfloat* |
| 1514 | get_Q(int i, int len) const override |
| 1515 | { |
| 1516 | Qfloat* data; |
| 1517 | int start; |
| 1518 | |
| 1519 | if ((start = cache->get_data(i, &data, len)) < len) { |
| 1520 | for (int j = start; j < len; j++) |
| 1521 | data[j] = static_cast<Qfloat>((this->*kernel_function)(i, j)); |
| 1522 | } |
| 1523 | |
| 1524 | return data; |
| 1525 | } |
| 1526 | |
| 1527 | double* |
| 1528 | get_QD() const override |
| 1529 | { |
| 1530 | return QD; |
| 1531 | } |
| 1532 | |
| 1533 | void |
| 1534 | swap_index(int i, int j) const override |
| 1535 | { |
| 1536 | cache->swap_index(i, j); |
| 1537 | Kernel::swap_index(i, j); |
| 1538 | swap(QD[i], QD[j]); |
| 1539 | } |
| 1540 | |
| 1541 | ~ONE_CLASS_Q() override |
| 1542 | { |
| 1543 | delete cache; |
| 1544 | delete[] QD; |
| 1545 | } |
| 1546 | |
| 1547 | private: |
| 1548 | Cache* cache; |
| 1549 | double* QD; |
| 1550 | }; |
| 1551 | |
| 1552 | class SVR_Q : public Kernel { |
| 1553 | |