Completed
Push — develop ( 933078...118ee0 )
by Arkadiusz
02:34
created

RBF::compute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Phpml\Math\Kernel;
5
6
use Phpml\Math\Kernel;
7
use Phpml\Math\Product;
8
9
class RBF implements Kernel
10
{
11
    /**
12
     * @var float
13
     */
14
    private $gamma;
15
16
    /**
17
     * @param float $gamma
18
     */
19
    public function __construct(float $gamma)
20
    {
21
        $this->gamma = $gamma;
22
    }
23
24
    /**
25
     * @param float $a
26
     * @param float $b
27
     *
28
     * @return float
29
     */
30
    public function compute($a, $b)
31
    {
32
        $score = 2 * Product::scalar($a, $b);
0 ignored issues
show
Documentation introduced by
$a is of type double, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$b is of type double, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
        $squares = Product::scalar($a, $a) + Product::scalar($b, $b);
0 ignored issues
show
Documentation introduced by
$a is of type double, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$b is of type double, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
34
        $result = exp(-$this->gamma * ($squares - $score));
35
36
        return $result;
37
    }
38
39
}
40