Skip to content

Commit aa77520

Browse files
author
counterclocker
committed
towards a decent printing system for all matrix like objects
1 parent 307500c commit aa77520

94 files changed

Lines changed: 32219 additions & 65625 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This is the multi-types version (last single type version: ce86f8476166f63d0af72
1313
my own source format...).
1414

1515
2. Cython memoryviews don't seem to be faster in our case. This should be assessed in the optimization phase. For the moment, I'll continue
16-
to code with NumPy's C-API. This is **not** the way Cython is intended by my tests indicate that this produces the fastest code. To be continued.
16+
to code with NumPy's C-API. This is **not** the way Cython is intended but my tests indicate that this produces the fastest code. To be continued.
1717

1818
Sorry for the fuzz.
1919

cysparse/sparse/ll_mat_matrices/ll_mat.cpx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ from cysparse.sparse.csr_mat_matrices.csr_mat_@index@_@type@ cimport MakeCSRSpar
1919
from cysparse.sparse.csc_mat_matrices.csc_mat_@index@_@type@ cimport MakeCSCSparseMatrix_@index@_@type@
2020

2121
from cysparse.sparse.sparse_utils.generic.generate_indices_@index@ cimport create_c_array_indices_from_python_object_@index@
22-
from cysparse.sparse.sparse_utils.generic.print_@type@ cimport element_to_string_@type@, empty_to_string_@type@
22+
from cysparse.sparse.sparse_utils.generic.print_@type@ cimport element_to_string_@type@, conjugated_element_to_string_@type@, empty_to_string_@type@
2323

2424
########################################################################################################################
2525
# CySparse include
@@ -2420,6 +2420,33 @@ YOU HAVE TO CAST YOUR NEW TYPE HERE
24202420
# element not found -> return empty cell
24212421
return empty_to_string_@type@(cell_width=cell_width)
24222422

2423+
def at_conj_to_string(self, @index@ i, @index@ j, int cell_width=10):
2424+
"""
2425+
Return a string with a given element if it exists or an "empty" string.
2426+
2427+
2428+
"""
2429+
cdef:
2430+
@index@ k, next_col
2431+
@type@ v
2432+
FLOAT64_t exp
2433+
2434+
# EXPLICIT TYPE TESTS
2435+
k = self.root[i]
2436+
while k != -1:
2437+
next_col = self.col[k]
2438+
if next_col >= j:
2439+
if next_col == j:
2440+
#v = self.val[k]
2441+
return conjugated_element_to_string_@type@(self.val[k], cell_width=cell_width)
2442+
else: # value not found
2443+
break
2444+
2445+
k = self.link[k]
2446+
2447+
# element not found -> return empty cell
2448+
return empty_to_string_@type@(cell_width=cell_width)
2449+
24232450
def print_to(self, OUT, width=9, print_big_matrices=False, transposed=False):
24242451
"""
24252452
Print content of matrix to output stream.

cysparse/sparse/ll_mat_matrices/ll_mat_INT32_t_COMPLEX128_t.c

Lines changed: 304 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cysparse/sparse/ll_mat_matrices/ll_mat_INT32_t_COMPLEX128_t.pyx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ from cysparse.sparse.csr_mat_matrices.csr_mat_INT32_t_COMPLEX128_t cimport MakeC
1919
from cysparse.sparse.csc_mat_matrices.csc_mat_INT32_t_COMPLEX128_t cimport MakeCSCSparseMatrix_INT32_t_COMPLEX128_t
2020

2121
from cysparse.sparse.sparse_utils.generic.generate_indices_INT32_t cimport create_c_array_indices_from_python_object_INT32_t
22-
from cysparse.sparse.sparse_utils.generic.print_COMPLEX128_t cimport element_to_string_COMPLEX128_t, empty_to_string_COMPLEX128_t
22+
from cysparse.sparse.sparse_utils.generic.print_COMPLEX128_t cimport element_to_string_COMPLEX128_t, conjugated_element_to_string_COMPLEX128_t, empty_to_string_COMPLEX128_t
2323

2424
########################################################################################################################
2525
# CySparse include
@@ -2246,6 +2246,33 @@ cdef class LLSparseMatrix_INT32_t_COMPLEX128_t(MutableSparseMatrix_INT32_t_COMPL
22462246
# element not found -> return empty cell
22472247
return empty_to_string_COMPLEX128_t(cell_width=cell_width)
22482248

2249+
def at_conj_to_string(self, INT32_t i, INT32_t j, int cell_width=10):
2250+
"""
2251+
Return a string with a given element if it exists or an "empty" string.
2252+
2253+
2254+
"""
2255+
cdef:
2256+
INT32_t k, next_col
2257+
COMPLEX128_t v
2258+
FLOAT64_t exp
2259+
2260+
# EXPLICIT TYPE TESTS
2261+
k = self.root[i]
2262+
while k != -1:
2263+
next_col = self.col[k]
2264+
if next_col >= j:
2265+
if next_col == j:
2266+
#v = self.val[k]
2267+
return conjugated_element_to_string_COMPLEX128_t(self.val[k], cell_width=cell_width)
2268+
else: # value not found
2269+
break
2270+
2271+
k = self.link[k]
2272+
2273+
# element not found -> return empty cell
2274+
return empty_to_string_COMPLEX128_t(cell_width=cell_width)
2275+
22492276
def print_to(self, OUT, width=9, print_big_matrices=False, transposed=False):
22502277
"""
22512278
Print content of matrix to output stream.

0 commit comments

Comments
 (0)