|
24 | 24 |
|
25 | 25 | from .fkernels import fget_vector_kernels_gaussian
|
26 | 26 | from .fkernels import fget_vector_kernels_laplacian
|
| 27 | +from .fkernels import fget_vector_kernels_gaussian_symmetric |
| 28 | +from .fkernels import fget_vector_kernels_laplacian_symmetric |
27 | 29 | from .fkernels import fget_local_kernels_gaussian
|
28 | 30 |
|
29 | 31 | from ..arad import get_local_kernels_arad
|
@@ -62,38 +64,52 @@ def get_atomic_kernels_laplacian(mols1, mols2, sigmas):
|
62 | 64 | return fget_vector_kernels_laplacian(x1, x2, n1, n2, sigmas,
|
63 | 65 | nm1, nm2, nsigmas)
|
64 | 66 |
|
| 67 | +def get_atomic_kernels_laplacian_symmetric(mols, sigmas): |
65 | 68 |
|
66 |
| -def get_atomic_kernels_gaussian(mols1, mols2, sigmas): |
| 69 | + n = np.array([mol.natoms for mol in mols], dtype=np.int32) |
67 | 70 |
|
68 |
| - n1 = np.array([mol.natoms for mol in mols1], dtype=np.int32) |
69 |
| - n2 = np.array([mol.natoms for mol in mols2], dtype=np.int32) |
| 71 | + max_atoms = np.max(n) |
70 | 72 |
|
71 |
| - max1 = np.max(n1) |
72 |
| - max2 = np.max(n2) |
| 73 | + nm = n.size |
73 | 74 |
|
74 |
| - nm1 = n1.size |
75 |
| - nm2 = n2.size |
| 75 | + cmat_size = mols[0].representation.shape[1] |
76 | 76 |
|
77 |
| - cmat_size = mols1[0].representation.shape[1] |
| 77 | + x = np.zeros((nm, max_atoms, cmat_size), dtype=np.float64, order="F") |
78 | 78 |
|
79 |
| - x1 = np.zeros((nm1, max1, cmat_size), dtype=np.float64, order="F") |
80 |
| - x2 = np.zeros((nm2, max2, cmat_size), dtype=np.float64, order="F") |
| 79 | + for imol in range(nm): |
| 80 | + x[imol,:n[imol],:cmat_size] = mols[imol].representation |
81 | 81 |
|
82 |
| - for imol in range(nm1): |
83 |
| - x1[imol,:n1[imol],:cmat_size] = mols1[imol].representation |
| 82 | + # Reorder for Fortran speed |
| 83 | + x = np.swapaxes(x, 0, 2) |
84 | 84 |
|
85 |
| - for imol in range(nm2): |
86 |
| - x2[imol,:n2[imol],:cmat_size] = mols2[imol].representation |
| 85 | + sigmas = np.asarray(sigmas, dtype=np.float64) |
| 86 | + nsigmas = sigmas.size |
| 87 | + |
| 88 | + return fget_vector_kernels_laplacian(x1, n, sigmas, nm, nsigmas) |
| 89 | + |
| 90 | + |
| 91 | +def get_atomic_kernels_gaussian(mols, sigmas): |
| 92 | + |
| 93 | + n = np.array([mol.natoms for mol in mols], dtype=np.int32) |
| 94 | + |
| 95 | + max_atoms = np.max(n) |
| 96 | + |
| 97 | + nm = n.size |
| 98 | + |
| 99 | + cmat_size = mols[0].representation.shape[1] |
| 100 | + |
| 101 | + x1 = np.zeros((nm, max_atoms, cmat_size), dtype=np.float64, order="F") |
| 102 | + |
| 103 | + for imol in range(nm1): |
| 104 | + x[imol,:n[imol],:cmat_size] = mols[imol].representation |
87 | 105 |
|
88 | 106 | # Reorder for Fortran speed
|
89 |
| - x1 = np.swapaxes(x1, 0, 2) |
90 |
| - x2 = np.swapaxes(x2, 0, 2) |
| 107 | + x = np.swapaxes(x, 0, 2) |
91 | 108 |
|
92 | 109 | sigmas = np.array(sigmas, dtype=np.float64)
|
93 | 110 | nsigmas = sigmas.size
|
94 | 111 |
|
95 |
| - return fget_vector_kernels_gaussian(x1, x2, n1, n2, sigmas, |
96 |
| - nm1, nm2, nsigmas) |
| 112 | + return fget_vector_kernels_gaussian(x, n, sigmas, nm, nsigmas) |
97 | 113 |
|
98 | 114 |
|
99 | 115 | def arad_local_kernels(mols1, mols2, sigmas,
|
@@ -125,3 +141,68 @@ def arad_local_symmetric_kernels(mols1, sigmas,
|
125 | 141 | width=width, cut_distance=cut_distance, r_width=r_width, c_width=c_width)
|
126 | 142 |
|
127 | 143 | return K
|
| 144 | + |
| 145 | +def get_atomic_kernels_laplacian(mols1, mols2, sigmas): |
| 146 | + |
| 147 | + n1 = np.array([mol.natoms for mol in mols1], dtype=np.int32) |
| 148 | + n2 = np.array([mol.natoms for mol in mols2], dtype=np.int32) |
| 149 | + |
| 150 | + max1 = np.max(n1) |
| 151 | + max2 = np.max(n2) |
| 152 | + |
| 153 | + nm1 = n1.size |
| 154 | + nm2 = n2.size |
| 155 | + |
| 156 | + cmat_size = mols1[0].representation.shape[1] |
| 157 | + |
| 158 | + x1 = np.zeros((nm1, max1, cmat_size), dtype=np.float64, order="F") |
| 159 | + x2 = np.zeros((nm2, max2, cmat_size), dtype=np.float64, order="F") |
| 160 | + |
| 161 | + for imol in range(nm1): |
| 162 | + x1[imol,:n1[imol],:cmat_size] = mols1[imol].representation |
| 163 | + |
| 164 | + for imol in range(nm2): |
| 165 | + x2[imol,:n2[imol],:cmat_size] = mols2[imol].representation |
| 166 | + |
| 167 | + # Reorder for Fortran speed |
| 168 | + x1 = np.swapaxes(x1, 0, 2) |
| 169 | + x2 = np.swapaxes(x2, 0, 2) |
| 170 | + |
| 171 | + sigmas = np.asarray(sigmas, dtype=np.float64) |
| 172 | + nsigmas = sigmas.size |
| 173 | + |
| 174 | + return fget_vector_kernels_laplacian(x1, x2, n1, n2, sigmas, |
| 175 | + nm1, nm2, nsigmas) |
| 176 | + |
| 177 | + |
| 178 | +def get_atomic_kernels_gaussian(mols1, mols2, sigmas): |
| 179 | + |
| 180 | + n1 = np.array([mol.natoms for mol in mols1], dtype=np.int32) |
| 181 | + n2 = np.array([mol.natoms for mol in mols2], dtype=np.int32) |
| 182 | + |
| 183 | + max1 = np.max(n1) |
| 184 | + max2 = np.max(n2) |
| 185 | + |
| 186 | + nm1 = n1.size |
| 187 | + nm2 = n2.size |
| 188 | + |
| 189 | + cmat_size = mols1[0].representation.shape[1] |
| 190 | + |
| 191 | + x1 = np.zeros((nm1, max1, cmat_size), dtype=np.float64, order="F") |
| 192 | + x2 = np.zeros((nm2, max2, cmat_size), dtype=np.float64, order="F") |
| 193 | + |
| 194 | + for imol in range(nm1): |
| 195 | + x1[imol,:n1[imol],:cmat_size] = mols1[imol].representation |
| 196 | + |
| 197 | + for imol in range(nm2): |
| 198 | + x2[imol,:n2[imol],:cmat_size] = mols2[imol].representation |
| 199 | + |
| 200 | + # Reorder for Fortran speed |
| 201 | + x1 = np.swapaxes(x1, 0, 2) |
| 202 | + x2 = np.swapaxes(x2, 0, 2) |
| 203 | + |
| 204 | + sigmas = np.array(sigmas, dtype=np.float64) |
| 205 | + nsigmas = sigmas.size |
| 206 | + |
| 207 | + return fget_vector_kernels_gaussian(x1, x2, n1, n2, sigmas, |
| 208 | + nm1, nm2, nsigmas) |
0 commit comments