Skip to content

Commit

Permalink
moving type declarations down
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Jul 22, 2024
1 parent 898c049 commit 430f9f5
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/sisl/_sparse_grid_ops.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
import cython
import cython.cimports.numpy as cnp
import numpy as np
Expand Down Expand Up @@ -136,8 +139,6 @@ def reduce_grid_sum(

need_transpose: cython.bint = new_axes.shape[0] > 1

row_value: cython.numeric

for i in range(nrows):

if need_transpose:
Expand All @@ -147,7 +148,7 @@ def reduce_grid_sum(
else:
reduced_i = i // reduce_factor

row_value = 0
row_value: cython.numeric = 0
for j in range(ptr[i], ptr[i + 1]):
row_value += data[j]

Expand Down Expand Up @@ -203,8 +204,6 @@ def reduce_grid_matvec_multiply(

need_transpose: cython.bint = new_axes.shape[0] > 1

row_value: cython.numeric

for i in range(nrows):
reduced_i = i // reduce_factor

Expand All @@ -215,7 +214,7 @@ def reduce_grid_matvec_multiply(
else:
reduced_i = i // reduce_factor

row_value = 0
row_value: cython.numeric = 0
for j in range(ptr[i], ptr[i + 1]):
jcol = col[j]
row_value += data[j] * V[jcol]
Expand Down Expand Up @@ -369,10 +368,6 @@ def reduce_sc_products(
jcol_sc: cython.int
jpair_sc: cython.int

# Temporal storage to build values
row_value: cython.floating
i_row_value: cython.floating

# Index to loop over axes of the grid.
iaxis: cython.int

Expand Down Expand Up @@ -415,16 +410,17 @@ def reduce_sc_products(
row_end = ptr[row + 1]

# Initialize the row value.
row_value = 0
row_value: cython.floating = 0

# For each row, loop over pairs of columns (ij).
# We add both ij and ji contributions, therefore we only need to loop over j greater than i.
# We do this because it is very easy if orbitals i and j are in the same cell. We also save
# some computation if they are not.
for i in range(row_start, row_end):
icol = col[i]

# Initialize the value for all pairs that we found for i
i_row_value = 0
i_row_value: cython.floating = 0

# Precompute the supercell index of icol (will compare it to that of jcol)
icol_sc = icol // uc_ncol
Expand Down

0 comments on commit 430f9f5

Please sign in to comment.