示例#1
0
 def gradient_points(
     self, points: np.ndarray, params: Union[List[float], List[Interval]]
 ) -> Union[List[np.ndarray], List[Interval]]:
     (alpha, ) = params
     x = points[:, 0]
     y = points[:, 1]
     z = points[:, 2]
     zero = iv.zeros_like(z)
     one = iv.ones_like(z)
     return [
         iv.stack(
             [iv.cos(alpha * z), iv.sin(alpha * z), zero],
             axis=1,
             convert=isinstance(alpha, Interval)),
         iv.stack([-iv.sin(alpha * z),
                   iv.cos(alpha * z), zero],
                  axis=1,
                  convert=isinstance(alpha, Interval)),
         iv.stack([
             alpha * (-iv.sin(alpha * z) * x - iv.cos(alpha * z) * y),
             alpha * (iv.cos(alpha * z) * x - iv.sin(alpha * z) * y), one
         ],
                  axis=1,
                  convert=isinstance(alpha, Interval)),
     ]
示例#2
0
 def hessian_points(self, points: np.ndarray, params: Union[List[float], List[Interval]]) -> Union[List[List[np.ndarray]], List[List[Interval]]]:
     a, b, theta = params
     z = points[:, 2]
     zero = iv.zeros_like(z)
     one = iv.ones_like(z)
     return [
         [
             iv.stack([
                 zero,
                 zero,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
             iv.stack([
                 zero,
                 zero,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
             iv.stack([
                 (0.5 * iv.square(a) + b) * iv.cos(theta) * one,
                 (0.5 * iv.square(a) + b) * iv.sin(theta) * one,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
         ],
         [
             iv.stack([
                 zero,
                 zero,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
             iv.stack([
                 zero,
                 zero,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
             iv.stack([
                 -(0.5 * iv.square(a) + b) * iv.sin(theta) * one,
                 (0.5 * iv.square(a) + b) * iv.cos(theta) * one,
                 zero
             ], axis=1, convert=isinstance(a, Interval))
         ],
         [
             iv.stack([
                 (0.5 * iv.square(a) + b) * iv.cos(theta) * one,
                 (0.5 * iv.square(a) + b) * iv.sin(theta) * one,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
             iv.stack([
                 -(0.5 * iv.square(a) + b) * iv.sin(theta) * one,
                 (0.5 * iv.square(a) + b) * iv.cos(theta) * one,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
             iv.stack([
                 zero,
                 zero,
                 zero
             ], axis=1, convert=isinstance(a, Interval))
         ],
     ]
示例#3
0
 def gradient_points(self, points: np.ndarray, params: Union[List[float], List[Interval]]) -> Union[List[np.ndarray], List[Interval]]:
     sx, sy = params
     z = points[:, 2]
     zero = iv.zeros_like(z)
     one = iv.ones_like(z)
     return [
         iv.stack([one, zero, zero], axis=1, convert=isinstance(sx, Interval)),
         iv.stack([zero, one, zero], axis=1, convert=isinstance(sx, Interval)),
         iv.stack([sx * one, sy * one, one], axis=1, convert=isinstance(sx, Interval)),
     ]
示例#4
0
 def hessian_points_params(self, points: np.ndarray, params: Union[List[float], List[Interval]]) -> Union[List[List[np.ndarray]], List[List[Interval]]]:
     a, b = params
     x = points[:, 0]
     zero = iv.zeros_like(x)
     one = iv.ones_like(x)
     return [
         [
             iv.stack([
                 -iv.sin(a) * one,
                 iv.cos(a) * one,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
             iv.stack([
                 zero,
                 zero,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
         ],
         [
             iv.stack([
                 -iv.cos(a) * iv.cos(b) * one,
                 -iv.sin(a) * iv.cos(b) * one,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
             iv.stack([
                 iv.sin(a) * iv.sin(b) * one,
                 -iv.cos(a) * iv.sin(b) * one,
                 iv.cos(b) * one
             ], axis=1, convert=isinstance(a, Interval)),
         ],
         [
             iv.stack([
                 iv.cos(a) * iv.sin(b) * one,
                 iv.sin(a) * iv.sin(b) * one,
                 zero
             ], axis=1, convert=isinstance(a, Interval)),
             iv.stack([
                 iv.sin(a) * iv.cos(b) * one,
                 -iv.cos(a) * iv.cos(b) * one,
                 -iv.sin(b) * one
             ], axis=1, convert=isinstance(a, Interval)),
         ]
     ]
示例#5
0
 def hessian_points_params(self, points: np.ndarray, params: Union[List[float], List[Interval]]) -> Union[List[List[np.ndarray]], List[List[Interval]]]:
     sx, sy = params
     x = points[:, 0]
     zero = iv.zeros_like(x)
     one = iv.ones_like(x)
     return [
         [
             iv.stack([zero, zero, zero], axis=1, convert=isinstance(sx, Interval)),
             iv.stack([zero, zero, zero], axis=1, convert=isinstance(sx, Interval)),
         ],
         [
             iv.stack([zero, zero, zero], axis=1, convert=isinstance(sx, Interval)),
             iv.stack([zero, zero, zero], axis=1, convert=isinstance(sx, Interval)),
         ],
         [
             iv.stack([one, zero, zero], axis=1, convert=isinstance(sx, Interval)),
             iv.stack([zero, one, zero], axis=1, convert=isinstance(sx, Interval)),
         ],
     ]
示例#6
0
 def gradient_points(
     self, points: np.ndarray, params: Union[List[float], List[Interval]]
 ) -> Union[List[np.ndarray], List[Interval]]:
     a, b = params
     x = points[:, 0]
     y = points[:, 1]
     z = points[:, 2]
     zero = iv.zeros_like(z)
     return [
         iv.stack([(0.5 * iv.square(a) * z + b * z + 1), zero, zero],
                  axis=1,
                  convert=isinstance(a, Interval)),
         iv.stack([zero, (0.5 * iv.square(a) * z + b * z + 1), zero],
                  axis=1,
                  convert=isinstance(a, Interval)),
         iv.stack([(0.5 * iv.square(a) + b) * x,
                   (0.5 * iv.square(a) + b) * y,
                   iv.ones_like(z)],
                  axis=1,
                  convert=isinstance(a, Interval)),
     ]
示例#7
0
 def gradient_points(self, points: np.ndarray, params: Union[List[float], List[Interval]]) -> Union[List[np.ndarray], List[Interval]]:
     a, b, theta = params
     x = points[:, 0]
     y = points[:, 1]
     z = points[:, 2]
     zero = iv.zeros_like(z)
     one = iv.ones_like(z)
     return [
         iv.stack([
             (0.5 * iv.square(a) * z + b * z + 1) * iv.cos(theta),
             (0.5 * iv.square(a) * z + b * z + 1) * iv.sin(theta),
             zero
         ], axis=1, convert=isinstance(a, Interval)),
         iv.stack([
             -(0.5 * iv.square(a) * z + b * z + 1) * iv.sin(theta),
             (0.5 * iv.square(a) * z + b * z + 1) * iv.cos(theta),
             zero
         ], axis=1, convert=isinstance(a, Interval)),
         iv.stack([
             (0.5 * iv.square(a) + b) * (iv.cos(theta) * x - iv.sin(theta) * y),
             (0.5 * iv.square(a) + b) * (iv.sin(theta) * x + iv.cos(theta) * y),
             one
         ], axis=1, convert=isinstance(a, Interval))
     ]