This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #521 from OP2/int64
* int64: Mark subblocks of monolithic matrices when calling assemble Introduce IntType and ScalarType and use everywhere
- Loading branch information
Showing
6 changed files
with
135 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import absolute_import, print_function, division | ||
|
||
import ctypes | ||
|
||
import numpy | ||
from petsc4py.PETSc import IntType, RealType, ScalarType | ||
|
||
IntType = numpy.dtype(IntType) | ||
RealType = numpy.dtype(RealType) | ||
ScalarType = numpy.dtype(ScalarType) | ||
|
||
|
||
def as_cstr(dtype): | ||
"""Convert a numpy dtype like object to a C type as a string.""" | ||
return {"bool": "unsigned char", | ||
"int": "int", | ||
"int8": "int8_t", | ||
"int16": "int16_t", | ||
"int32": "int32_t", | ||
"int64": "int64_t", | ||
"uint8": "uint8_t", | ||
"uint16": "uint16_t", | ||
"uint32": "uint32_t", | ||
"uint64": "uint64_t", | ||
"float32": "float", | ||
"float64": "double"}[numpy.dtype(dtype).name] | ||
|
||
|
||
def as_ctypes(dtype): | ||
"""Convert a numpy dtype like object to a ctypes type.""" | ||
return {"bool": ctypes.c_bool, | ||
"int": ctypes.c_int, | ||
"int8": ctypes.c_char, | ||
"int16": ctypes.c_int16, | ||
"int32": ctypes.c_int32, | ||
"int64": ctypes.c_int64, | ||
"uint8": ctypes.c_ubyte, | ||
"uint16": ctypes.c_uint16, | ||
"uint32": ctypes.c_uint32, | ||
"uint64": ctypes.c_uint64, | ||
"float32": ctypes.c_float, | ||
"float64": ctypes.c_double}[numpy.dtype(dtype).name] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.