|
| 1 | +from typing import List, Union |
| 2 | + |
1 | 3 | import numpy as np
|
| 4 | +from numpy import ndarray |
2 | 5 |
|
3 | 6 | from qmllib.utils.environment_manipulation import (
|
4 | 7 | mkl_get_num_threads,
|
|
22 | 25 | )
|
23 | 26 |
|
24 | 27 |
|
25 |
| -def get_global_kernel(X1, X2, Q1, Q2, SIGMA): |
| 28 | +def get_global_kernel( |
| 29 | + X1: ndarray, X2: ndarray, Q1: List[List[int]], Q2: List[List[int]], SIGMA: float |
| 30 | +) -> ndarray: |
26 | 31 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
27 | 32 |
|
28 | 33 | :math:`K_{ij} = \\sum_{I\\in i} \\sum_{J\\in j}\\exp \\big( -\\frac{\\|X_I - X_J\\|_2^2}{2\\sigma^2} \\big)`
|
@@ -75,7 +80,9 @@ def get_global_kernel(X1, X2, Q1, Q2, SIGMA):
|
75 | 80 | return K
|
76 | 81 |
|
77 | 82 |
|
78 |
| -def get_local_kernels(X1, X2, Q1, Q2, SIGMAS): |
| 83 | +def get_local_kernels( |
| 84 | + X1: ndarray, X2: ndarray, Q1: List[List[int]], Q2: List[List[int]], SIGMAS: List[float] |
| 85 | +) -> ndarray: |
79 | 86 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
80 | 87 |
|
81 | 88 | :math:`K_{ij} = \\sum_{I\\in i} \\sum_{J\\in j}\\exp \\big( -\\frac{\\|X_I - X_J\\|_2^2}{2\\sigma^2} \\big)`
|
@@ -131,7 +138,13 @@ def get_local_kernels(X1, X2, Q1, Q2, SIGMAS):
|
131 | 138 | return K
|
132 | 139 |
|
133 | 140 |
|
134 |
| -def get_local_kernel(X1, X2, Q1, Q2, SIGMA): |
| 141 | +def get_local_kernel( |
| 142 | + X1: ndarray, |
| 143 | + X2: ndarray, |
| 144 | + Q1: List[Union[ndarray, List[int]]], |
| 145 | + Q2: List[Union[ndarray, List[int]]], |
| 146 | + SIGMA: float, |
| 147 | +) -> ndarray: |
135 | 148 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
136 | 149 |
|
137 | 150 | :math:`K_{ij} = \\sum_{I\\in i} \\sum_{J\\in j}\\exp \\big( -\\frac{\\|X_I - X_J\\|_2^2}{2\\sigma^2} \\big)`
|
@@ -184,7 +197,7 @@ def get_local_kernel(X1, X2, Q1, Q2, SIGMA):
|
184 | 197 | return K
|
185 | 198 |
|
186 | 199 |
|
187 |
| -def get_local_symmetric_kernels(X1, Q1, SIGMAS): |
| 200 | +def get_local_symmetric_kernels(X1: ndarray, Q1: List[List[int]], SIGMAS: List[float]) -> ndarray: |
188 | 201 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
189 | 202 |
|
190 | 203 | :math:`K_{ij} = \\sum_{I\\in i} \\sum_{J\\in j}\\exp \\big( -\\frac{\\|X_I - X_J\\|_2^2}{2\\sigma^2} \\big)`
|
@@ -229,7 +242,9 @@ def get_local_symmetric_kernels(X1, Q1, SIGMAS):
|
229 | 242 | return K
|
230 | 243 |
|
231 | 244 |
|
232 |
| -def get_local_symmetric_kernel(X1, Q1, SIGMA): |
| 245 | +def get_local_symmetric_kernel( |
| 246 | + X1: ndarray, Q1: List[Union[ndarray, List[int]]], SIGMA: float |
| 247 | +) -> ndarray: |
233 | 248 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
234 | 249 |
|
235 | 250 | :math:`K_{ij} = \\sum_{I\\in i} \\sum_{J\\in j}\\exp \\big( -\\frac{\\|X_I - X_J\\|_2^2}{2\\sigma^2} \\big)`
|
@@ -273,7 +288,13 @@ def get_local_symmetric_kernel(X1, Q1, SIGMA):
|
273 | 288 | return K
|
274 | 289 |
|
275 | 290 |
|
276 |
| -def get_atomic_local_kernel(X1, X2, Q1, Q2, SIGMA): |
| 291 | +def get_atomic_local_kernel( |
| 292 | + X1: ndarray, |
| 293 | + X2: ndarray, |
| 294 | + Q1: List[Union[ndarray, List[int]]], |
| 295 | + Q2: List[Union[ndarray, List[int]]], |
| 296 | + SIGMA: float, |
| 297 | +) -> ndarray: |
277 | 298 |
|
278 | 299 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
279 | 300 |
|
@@ -332,7 +353,14 @@ def get_atomic_local_kernel(X1, X2, Q1, Q2, SIGMA):
|
332 | 353 | return K
|
333 | 354 |
|
334 | 355 |
|
335 |
| -def get_atomic_local_gradient_kernel(X1, X2, dX2, Q1, Q2, SIGMA): |
| 356 | +def get_atomic_local_gradient_kernel( |
| 357 | + X1: ndarray, |
| 358 | + X2: ndarray, |
| 359 | + dX2: ndarray, |
| 360 | + Q1: List[Union[ndarray, List[int]]], |
| 361 | + Q2: List[Union[ndarray, List[int]]], |
| 362 | + SIGMA: float, |
| 363 | +) -> ndarray: |
336 | 364 |
|
337 | 365 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
338 | 366 |
|
@@ -412,7 +440,9 @@ def get_atomic_local_gradient_kernel(X1, X2, dX2, Q1, Q2, SIGMA):
|
412 | 440 | return K
|
413 | 441 |
|
414 | 442 |
|
415 |
| -def get_local_gradient_kernel(X1, X2, dX2, Q1, Q2, SIGMA): |
| 443 | +def get_local_gradient_kernel( |
| 444 | + X1: ndarray, X2: ndarray, dX2: ndarray, Q1: List[List[int]], Q2: List[List[int]], SIGMA: float |
| 445 | +) -> ndarray: |
416 | 446 |
|
417 | 447 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
418 | 448 |
|
@@ -478,7 +508,15 @@ def get_local_gradient_kernel(X1, X2, dX2, Q1, Q2, SIGMA):
|
478 | 508 | return K
|
479 | 509 |
|
480 | 510 |
|
481 |
| -def get_gdml_kernel(X1, X2, dX1, dX2, Q1, Q2, SIGMA): |
| 511 | +def get_gdml_kernel( |
| 512 | + X1: ndarray, |
| 513 | + X2: ndarray, |
| 514 | + dX1: ndarray, |
| 515 | + dX2: ndarray, |
| 516 | + Q1: List[List[int]], |
| 517 | + Q2: List[List[int]], |
| 518 | + SIGMA: float, |
| 519 | +) -> ndarray: |
482 | 520 |
|
483 | 521 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
484 | 522 |
|
@@ -560,7 +598,9 @@ def get_gdml_kernel(X1, X2, dX1, dX2, Q1, Q2, SIGMA):
|
560 | 598 | return K
|
561 | 599 |
|
562 | 600 |
|
563 |
| -def get_symmetric_gdml_kernel(X1, dX1, Q1, SIGMA): |
| 601 | +def get_symmetric_gdml_kernel( |
| 602 | + X1: ndarray, dX1: ndarray, Q1: List[List[int]], SIGMA: float |
| 603 | +) -> ndarray: |
564 | 604 |
|
565 | 605 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
566 | 606 |
|
@@ -613,7 +653,15 @@ def get_symmetric_gdml_kernel(X1, dX1, Q1, SIGMA):
|
613 | 653 | return K
|
614 | 654 |
|
615 | 655 |
|
616 |
| -def get_gp_kernel(X1, X2, dX1, dX2, Q1, Q2, SIGMA): |
| 656 | +def get_gp_kernel( |
| 657 | + X1: ndarray, |
| 658 | + X2: ndarray, |
| 659 | + dX1: ndarray, |
| 660 | + dX2: ndarray, |
| 661 | + Q1: List[Union[ndarray, List[int]]], |
| 662 | + Q2: List[Union[ndarray, List[int]]], |
| 663 | + SIGMA: float, |
| 664 | +) -> ndarray: |
617 | 665 |
|
618 | 666 | """Calculates the Gaussian kernel matrix K with the local decomposition where :math:`K_{ij}`:
|
619 | 667 |
|
@@ -692,7 +740,9 @@ def get_gp_kernel(X1, X2, dX1, dX2, Q1, Q2, SIGMA):
|
692 | 740 | return K
|
693 | 741 |
|
694 | 742 |
|
695 |
| -def get_symmetric_gp_kernel(X1, dX1, Q1, SIGMA): |
| 743 | +def get_symmetric_gp_kernel( |
| 744 | + X1: ndarray, dX1: ndarray, Q1: List[Union[ndarray, List[int]]], SIGMA: float |
| 745 | +) -> ndarray: |
696 | 746 |
|
697 | 747 | """
|
698 | 748 | This symmetric kernel corresponds to a Gaussian process regression (GPR) approach.
|
|
0 commit comments