()
| 377 | } |
| 378 | |
| 379 | func (this *Solver) reconstruct_gradient() { |
| 380 | // reconstruct inactive elements of G from G_bar and free variables |
| 381 | |
| 382 | if this.active_size == this.l { |
| 383 | return |
| 384 | } |
| 385 | var i, j int |
| 386 | nr_free := 0 |
| 387 | |
| 388 | for j = this.active_size; j < this.l; j++ { |
| 389 | this.G[j] = this.G_bar[j] + this.p[j] |
| 390 | } |
| 391 | for j = 0; j < this.active_size; j++ { |
| 392 | if this.is_free(j) { |
| 393 | nr_free++ |
| 394 | } |
| 395 | } |
| 396 | if (2 * nr_free) < this.active_size { |
| 397 | log.Fatal("\nWARNING: using -h 0 may be faster\n") |
| 398 | } |
| 399 | |
| 400 | if (nr_free * this.l) > (2 * this.active_size * (this.l - this.active_size)) { |
| 401 | for i = this.active_size; i < this.l; i++ { |
| 402 | Q_i := this.Q.get_Q(i, this.active_size) |
| 403 | for j = 0; j < this.active_size; j++ { |
| 404 | if this.is_free(j) { |
| 405 | this.G[i] += this.alpha[j] * float64(Q_i[j]) |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | } else { |
| 410 | for i = 0; i < this.active_size; i++ { |
| 411 | if this.is_free(i) { |
| 412 | Q_i := this.Q.get_Q(i, this.l) |
| 413 | alpha_i := this.alpha[i] |
| 414 | for j = this.active_size; j < this.l; j++ { |
| 415 | this.G[j] += alpha_i * float64(Q_i[j]) |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | func (this *Solver) Solve(l int, Q QMatrix, p_ []float64, y_ []int8, alpha_ []float64, Cp, Cn, eps float64, si *SolutionInfo, shrinking int) { |
| 423 | this.l = l |
no test coverage detected