foscat.BkBase ============= .. py:module:: foscat.BkBase Classes ------- .. autoapisummary:: foscat.BkBase.BackendBase Module Contents --------------- .. py:class:: BackendBase(name, mpi_rank=0, all_type='float64', gpupos=0, silent=False) .. py:attribute:: BACKEND .. py:attribute:: mpi_rank :value: 0 .. py:attribute:: all_type :value: 'float64' .. py:attribute:: gpupos :value: 0 .. py:attribute:: silent :value: False .. py:method:: to_dict() .. py:method:: iso_mean(x, use_2D=False) .. py:method:: fft_ang(x, nharm=1, imaginary=False, use_2D=False) .. py:method:: calc_iso_orient(norient) .. py:method:: calc_iso_orient3(norient) Build the averaging matrix for 3-orientation isotropic reduction (S4). S4 has shape [..., L1, L2, L3]. Under a global rotation by δ the three orientation indices shift together: l_k → (l_k + δ) mod L. The only rotationally-invariant quantities are the two *relative* angles Δl12 = (l2 - l1) mod L Δl13 = (l3 - l1) mod L The forward matrix (shape [L^3, L^2]) maps the flat (l1, l2, l3) index to the flat (Δl12, Δl13) index with weight 1/L: output[Δl12, Δl13] = (1/L) Σ_{l1} input[l1, (l1+Δl12)%L, (l1+Δl13)%L] The transpose matrix (shape [L^2, L^3], weight L·tmpᵀ) is the pseudo- inverse used by the ``repeat=True`` path to reconstruct a full [..., L, L, L] tensor from the [..., L, L] isotropic representation. .. py:method:: calc_fft_orient(norient, nharm, imaginary) .. py:method:: calc_fft_ang_orient(norient, nharm, imaginary) Build projection matrices for the angular-FFT reduction of S3/S4. Unlike the tensor-product ``_fft_2_orient`` / ``_fft_3_orient`` matrices (which apply independent 1-D FFTs on each orientation axis), these matrices first reindex (l1, l2) → (Δl, l1) and then project the l1 axis onto the Fourier basis, keeping the Δl (relative-orientation) axis intact. Results ------- _fft_ang2_orient[(norient, nharm, imaginary)] : shape [L*L, L*nout] Maps S3[l1, l2] (flat [L²]) → out[Δl, k] (flat [L*nout]) where Δl = (l2-l1) % L and k indexes the Fourier basis on l1. _fft_ang3_orient[(norient, nharm, imaginary)] : shape [L*L*L, L*L*nout] Maps S4[l1, l2, l3] (flat [L³]) → out[Δl12, Δl13, k] (flat [L²*nout]) where Δl12 = (l2-l1)%L, Δl13 = (l3-l1)%L. .. py:method:: bk_len(S) :abstractmethod: .. py:method:: bk_SparseTensor(indice, w, dense_shape=[]) :abstractmethod: .. py:method:: bk_stack(list, axis=0) :abstractmethod: .. py:method:: bk_sparse_dense_matmul(smat, mat) :abstractmethod: .. py:method:: conv2d(x, w, strides=[1, 1, 1, 1], padding='SAME') :abstractmethod: .. py:method:: conv1d(x, w, strides=[1, 1, 1], padding='SAME') :abstractmethod: .. py:method:: bk_threshold(x, threshold, greater=True) :abstractmethod: .. py:method:: bk_maximum(x1, x2) :abstractmethod: .. py:method:: bk_device(device_name) :abstractmethod: .. py:method:: bk_ones(shape, dtype=None) :abstractmethod: .. py:method:: bk_conv1d(x, w) :abstractmethod: .. py:method:: bk_flattenR(x) :abstractmethod: .. py:method:: bk_flatten(x) :abstractmethod: .. py:method:: bk_size(x) :abstractmethod: .. py:method:: bk_resize_image(x, shape) :abstractmethod: .. py:method:: bk_L1(x) :abstractmethod: .. py:method:: bk_square_comp(x) :abstractmethod: .. py:method:: bk_reduce_sum(data, axis=None) :abstractmethod: .. py:method:: bk_reduce_mean(data, axis=None) :abstractmethod: .. py:method:: bk_reduce_min(data, axis=None) :abstractmethod: .. py:method:: bk_random_seed(value) :abstractmethod: .. py:method:: bk_random_uniform(shape) :abstractmethod: .. py:method:: bk_reduce_std(data, axis=None) :abstractmethod: .. py:method:: bk_sqrt(data) :abstractmethod: .. py:method:: bk_abs(data) :abstractmethod: .. py:method:: bk_is_complex(data) :abstractmethod: .. py:method:: bk_distcomp(data) :abstractmethod: .. py:method:: bk_norm(data) :abstractmethod: .. py:method:: bk_square(data) :abstractmethod: .. py:method:: bk_log(data) :abstractmethod: .. py:method:: bk_matmul(a, b) :abstractmethod: .. py:method:: bk_tensor(data) :abstractmethod: .. py:method:: bk_shape_tensor(shape) :abstractmethod: .. py:method:: bk_complex(real, imag) :abstractmethod: .. py:method:: bk_exp(data) :abstractmethod: .. py:method:: bk_min(data) :abstractmethod: .. py:method:: bk_argmin(data) :abstractmethod: .. py:method:: bk_tanh(data) :abstractmethod: .. py:method:: bk_max(data) :abstractmethod: .. py:method:: bk_argmax(data) :abstractmethod: .. py:method:: bk_reshape(data, shape) :abstractmethod: .. py:method:: bk_repeat(data, nn, axis=0) :abstractmethod: .. py:method:: bk_tile(data, nn, axis=0) :abstractmethod: .. py:method:: bk_roll(data, nn, axis=0) :abstractmethod: .. py:method:: bk_expand_dims(data, axis=0) :abstractmethod: .. py:method:: bk_transpose(data, thelist) :abstractmethod: .. py:method:: bk_concat(data, axis=None) :abstractmethod: .. py:method:: bk_zeros(shape, dtype=None) :abstractmethod: .. py:method:: bk_gather(data, idx) :abstractmethod: .. py:method:: bk_reverse(data, axis=0) :abstractmethod: .. py:method:: bk_fft(data) :abstractmethod: .. py:method:: bk_fftn(data, dim=None) :abstractmethod: .. py:method:: bk_ifftn(data, dim=None, norm=None) :abstractmethod: .. py:method:: bk_rfft(data) :abstractmethod: .. py:method:: bk_irfft(data) :abstractmethod: .. py:method:: bk_conjugate(data) :abstractmethod: .. py:method:: bk_real(data) :abstractmethod: .. py:method:: bk_imag(data) :abstractmethod: .. py:method:: bk_relu(x) :abstractmethod: .. py:method:: bk_clip_by_value(x, xmin, xmax) :abstractmethod: .. py:method:: bk_cast(x) :abstractmethod: .. py:method:: bk_variable(x) :abstractmethod: .. py:method:: bk_assign(x, y) :abstractmethod: .. py:method:: bk_constant(x) :abstractmethod: .. py:method:: bk_cos(x) :abstractmethod: .. py:method:: bk_sin(x) :abstractmethod: .. py:method:: bk_arctan2(c, s) :abstractmethod: .. py:method:: bk_empty(list) :abstractmethod: .. py:method:: to_numpy(x) :abstractmethod: