[Scipy-svn] r3548 - in trunk: . scipy/io/tests scipy/ndimage scipy/ndimage/segment/tests scipy/ndimage/tests scipy/sandbox/montecarlo/examples scipy/sandbox/multigrid scipy/sandbox/multigrid/multigridtools scipy/sandbox/multigrid/tests scipy/sparse scipy/sparse/sparsetools scipy/stats/models/robust
scipy-svn@scip...
scipy-svn@scip...
Sun Nov 18 22:13:58 CST 2007
Author: jarrod.millman
Date: 2007-11-18 22:13:22 -0600 (Sun, 18 Nov 2007)
New Revision: 3548
Modified:
trunk/scipy/io/tests/test_datasource.py
trunk/scipy/ndimage/segment/tests/test_segment.py
trunk/scipy/ndimage/segmenter.py
trunk/scipy/ndimage/tests/test_segment.py
trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py
trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py
trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py
trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py
trunk/scipy/sandbox/multigrid/adaptive.py
trunk/scipy/sandbox/multigrid/dec_test.py
trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py
trunk/scipy/sandbox/multigrid/multilevel.py
trunk/scipy/sandbox/multigrid/tests/test_utils.py
trunk/scipy/sandbox/multigrid/utils.py
trunk/scipy/sparse/sparse.py
trunk/scipy/sparse/sparsetools/sparsetools.py
trunk/scipy/stats/models/robust/scale.py
trunk/setup.py
Log:
ran reindent.py to cleanup whitespaces
Modified: trunk/scipy/io/tests/test_datasource.py
===================================================================
--- trunk/scipy/io/tests/test_datasource.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/io/tests/test_datasource.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -85,7 +85,7 @@
def test_ValidHTTP(self):
assert self.ds.open(valid_httpurl())
-
+
def test_InvalidHTTP(self):
self.assertRaises(IOError, self.ds.open, invalid_httpurl())
@@ -131,7 +131,7 @@
def test_ValidHTTP(self):
assert self.ds.exists(valid_httpurl())
-
+
def test_InvalidHTTP(self):
self.assertEqual(self.ds.exists(invalid_httpurl()), False)
@@ -240,7 +240,7 @@
class TestOpenFunc(NumpyTestCase):
def setUp(self):
self.tmpdir = mkdtemp()
-
+
def tearDown(self):
rmtree(self.tmpdir)
@@ -254,4 +254,3 @@
if __name__ == "__main__":
NumpyTest().run()
-
Modified: trunk/scipy/ndimage/segment/tests/test_segment.py
===================================================================
--- trunk/scipy/ndimage/segment/tests/test_segment.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/ndimage/segment/tests/test_segment.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -11,302 +11,302 @@
def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048,
highThreshold=600+2048, dust=16):
- """
- labeledEdges, ROIList = shen_castan(image, [default])
+ """
+ labeledEdges, ROIList = shen_castan(image, [default])
- implements Shen-Castan edge finding
+ implements Shen-Castan edge finding
- Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust
- - image is the numarray 2D image
- - IIR filter is filter parameter for exponential filter
- - shen_castan_low is edge threshold is range (0.0, 1.0]
- - window is search window for edge detection
- - low_ and high_ threshold are density values
- - dust is blob filter. blob area (length x width of bounding box) under this
- size threshold are filtered (referred to as dust and blown away)
+ Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust
+ - image is the numarray 2D image
+ - IIR filter is filter parameter for exponential filter
+ - shen_castan_low is edge threshold is range (0.0, 1.0]
+ - window is search window for edge detection
+ - low_ and high_ threshold are density values
+ - dust is blob filter. blob area (length x width of bounding box) under this
+ size threshold are filtered (referred to as dust and blown away)
- Outputs - labeledEdges, ROIList[>dust]
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList[>dust] is a blob feature list. Only values
- with bounding box area greater than dust threshold are returned
+ Outputs - labeledEdges, ROIList[>dust]
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList[>dust] is a blob feature list. Only values
+ with bounding box area greater than dust threshold are returned
- """
- labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window,
- lowThreshold, highThreshold, image)
- # allocated struct array for edge object measures. for now just the rect bounding box
- ROIList = N.zeros(numberObjects, dtype=S.objstruct)
- # return the bounding box for each connected edge
- S.get_object_stats(labeledEdges, ROIList)
- return labeledEdges, ROIList[ROIList['Area']>dust]
+ """
+ labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window,
+ lowThreshold, highThreshold, image)
+ # allocated struct array for edge object measures. for now just the rect bounding box
+ ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+ # return the bounding box for each connected edge
+ S.get_object_stats(labeledEdges, ROIList)
+ return labeledEdges, ROIList[ROIList['Area']>dust]
def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0,
apearture=21, dust=16):
- """
- labeledEdges, ROIList = sobel(image, [default])
+ """
+ labeledEdges, ROIList = sobel(image, [default])
- implements sobel magnitude edge finding
+ implements sobel magnitude edge finding
- Inputs - image, sobel_low, tMode, low_threshold, high_threshold,
- high_filter_cutoff, filter_aperature, dust
- - image is the numarray 2D image
- - sobel_low is edge threshold is range (0.0, 1.0]
- - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak)
- - low_ and high_ threshold are density values
- - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
- - aperature is odd filter kernel length
- - dust is blob filter. blob area (length x width of bounding box) under this
- size threshold are filtered (referred to as dust and blown away)
+ Inputs - image, sobel_low, tMode, low_threshold, high_threshold,
+ high_filter_cutoff, filter_aperature, dust
+ - image is the numarray 2D image
+ - sobel_low is edge threshold is range (0.0, 1.0]
+ - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak)
+ - low_ and high_ threshold are density values
+ - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
+ - aperature is odd filter kernel length
+ - dust is blob filter. blob area (length x width of bounding box) under this
+ size threshold are filtered (referred to as dust and blown away)
- Outputs - labeledEdges, ROIList[>dust]
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList[>dust] is a blob feature list. Only values
- with bounding box area greater than dust threshold are returned
+ Outputs - labeledEdges, ROIList[>dust]
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList[>dust] is a blob feature list. Only values
+ with bounding box area greater than dust threshold are returned
- """
- # get sobel edge points. return edges that are labeled (1..numberObjects)
- labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold,
- highThreshold, BPHigh, apearture, image)
- # allocated struct array for edge object measures. for now just the rect bounding box
- ROIList = N.zeros(numberObjects, dtype=S.objstruct)
- # return the bounding box for each connected edge
- S.get_object_stats(labeledEdges, ROIList)
- # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge'
- S.morpho_thin_filt(labeledEdges, ROIList)
- return labeledEdges, ROIList[ROIList['Area']>dust]
+ """
+ # get sobel edge points. return edges that are labeled (1..numberObjects)
+ labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold,
+ highThreshold, BPHigh, apearture, image)
+ # allocated struct array for edge object measures. for now just the rect bounding box
+ ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+ # return the bounding box for each connected edge
+ S.get_object_stats(labeledEdges, ROIList)
+ # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge'
+ S.morpho_thin_filt(labeledEdges, ROIList)
+ return labeledEdges, ROIList[ROIList['Area']>dust]
def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048,
highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16):
- """
- labeledEdges, ROIList = canny(image, [default])
+ """
+ labeledEdges, ROIList = canny(image, [default])
- implements canny edge finding
+ implements canny edge finding
- Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold,
- high_threshold, high_filter_cutoff, filter_aperature, dust
- - image is the numarray 2D image
- - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter
- - clow is low edge threshold is range (0.0, 1.0]
- - chigh is high edge threshold is range (0.0, 1.0]
- - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak)
- - low_ and high_ threshold are density values
- - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
- - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
- - aperature is odd filter kernel length
- - dust is blob filter. blob area (length x width of bounding box) under this
- size threshold are filtered (referred to as dust and blown away)
+ Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold,
+ high_threshold, high_filter_cutoff, filter_aperature, dust
+ - image is the numarray 2D image
+ - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter
+ - clow is low edge threshold is range (0.0, 1.0]
+ - chigh is high edge threshold is range (0.0, 1.0]
+ - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak)
+ - low_ and high_ threshold are density values
+ - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
+ - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
+ - aperature is odd filter kernel length
+ - dust is blob filter. blob area (length x width of bounding box) under this
+ size threshold are filtered (referred to as dust and blown away)
- Outputs - labeledEdges, ROIList[>dust]
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList[>dust] is a blob feature list. Only values
- with bounding box area greater than dust threshold are returned
+ Outputs - labeledEdges, ROIList[>dust]
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList[>dust] is a blob feature list. Only values
+ with bounding box area greater than dust threshold are returned
- """
- # get canny edge points. return edges that are labeled (1..numberObjects)
- labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold,
- BPHigh, apearture, image)
- # allocated struct array for edge object measures. for now just the rect bounding box
- ROIList = N.zeros(numberObjects, dtype=S.objstruct)
- # return the bounding box for each connected edge
- S.get_object_stats(labeledEdges, ROIList)
- return labeledEdges, ROIList[ROIList['Area']>dust]
+ """
+ # get canny edge points. return edges that are labeled (1..numberObjects)
+ labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold,
+ BPHigh, apearture, image)
+ # allocated struct array for edge object measures. for now just the rect bounding box
+ ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+ # return the bounding box for each connected edge
+ S.get_object_stats(labeledEdges, ROIList)
+ return labeledEdges, ROIList[ROIList['Area']>dust]
def get_shape_mask(labeledEdges, ROIList):
- """
- get_shape_mask(labeledEdges, ROIList)
+ """
+ get_shape_mask(labeledEdges, ROIList)
- takes labeled edge image plus ROIList (blob descriptors) and generates
- boundary shape features and builds labeled blob masks. 'labeledEdges'
- is over-written by 'labeledMask'. Adds features to ROIList structure
+ takes labeled edge image plus ROIList (blob descriptors) and generates
+ boundary shape features and builds labeled blob masks. 'labeledEdges'
+ is over-written by 'labeledMask'. Adds features to ROIList structure
- Inputs - labeledEdges, ROIList
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList is a blob feature list.
+ Inputs - labeledEdges, ROIList
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList is a blob feature list.
- Output - no return. edge image input is over-written with mask image.
- ROIList added to.
+ Output - no return. edge image input is over-written with mask image.
+ ROIList added to.
- """
+ """
- # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList
- # GetShapeMask will augment the ROI list
- # labeledEdges is the original edge image and overwritten as mask image
- # maskImage is the mask that is used for blob texture / pixel features
- S.build_boundary(labeledEdges, ROIList)
- return
+ # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList
+ # GetShapeMask will augment the ROI list
+ # labeledEdges is the original edge image and overwritten as mask image
+ # maskImage is the mask that is used for blob texture / pixel features
+ S.build_boundary(labeledEdges, ROIList)
+ return
def get_voxel_measures(rawImage, labeledEdges, ROIList):
- """
- get_voxel_measures(rawImage, labeledEdges, ROIList)
+ """
+ get_voxel_measures(rawImage, labeledEdges, ROIList)
- takes raw 2D image, labeled blob mask and ROIList. computes voxel features
- (moments, histogram) for each blob. Adds features to ROIList structure.
+ takes raw 2D image, labeled blob mask and ROIList. computes voxel features
+ (moments, histogram) for each blob. Adds features to ROIList structure.
- Inputs - rawImage, labeledEdges, ROIList
- - rawImage is the original source 2D image
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList is a blob feature list.
+ Inputs - rawImage, labeledEdges, ROIList
+ - rawImage is the original source 2D image
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList is a blob feature list.
- Output - no return. ROIList added to.
+ Output - no return. ROIList added to.
- """
- #
- # pass raw image, labeled mask and the partially filled ROIList
- # VoxelMeasures will fill the voxel features in the list
- #
- S.voxel_measures(rawImage, labeledEdges, ROIList)
- return
+ """
+ #
+ # pass raw image, labeled mask and the partially filled ROIList
+ # VoxelMeasures will fill the voxel features in the list
+ #
+ S.voxel_measures(rawImage, labeledEdges, ROIList)
+ return
def get_texture_measures(rawImage, labeledEdges, ROIList):
- """
- get_texture_measures(rawImage, labeledEdges, ROIList)
+ """
+ get_texture_measures(rawImage, labeledEdges, ROIList)
- takes raw 2D image, labeled blob mask and ROIList. computes 2D
- texture features using 7x7 Law's texture filters applied
- to segmented blobs. TEM (texture energy metric) is computed
- for each Law's filter image and stored in TEM part of ROIList.
+ takes raw 2D image, labeled blob mask and ROIList. computes 2D
+ texture features using 7x7 Law's texture filters applied
+ to segmented blobs. TEM (texture energy metric) is computed
+ for each Law's filter image and stored in TEM part of ROIList.
- Inputs - rawImage, labeledEdges, ROIList
- - rawImage is the original source 2D image
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList is a blob feature list.
+ Inputs - rawImage, labeledEdges, ROIList
+ - rawImage is the original source 2D image
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList is a blob feature list.
- Output - no return. ROIList added to.
- """
- #
- # pass raw image, labeled mask and the partially filled ROIList
- # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list
- #
- S.texture_measures(rawImage, labeledEdges, ROIList)
- return
+ Output - no return. ROIList added to.
+ """
+ #
+ # pass raw image, labeled mask and the partially filled ROIList
+ # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list
+ #
+ S.texture_measures(rawImage, labeledEdges, ROIList)
+ return
def segment_regions():
- """
- sourceImage, labeledMask, ROIList = segment_regions()
+ """
+ sourceImage, labeledMask, ROIList = segment_regions()
- Inputs - No Input
+ Inputs - No Input
- Outputs - sourceImage, labeledMask, ROIList
- - sourceImage is raw 2D image (default cardiac CT slice for demo
- - labeledMask is mask of segmented 'blobs',
- numerically labeled by blob number
- - ROIList is numerical Python structure of intensity, shape and
- texture features for each blob
+ Outputs - sourceImage, labeledMask, ROIList
+ - sourceImage is raw 2D image (default cardiac CT slice for demo
+ - labeledMask is mask of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList is numerical Python structure of intensity, shape and
+ texture features for each blob
- High level script calls Python functions:
- get_slice() - a cardiac CT slice demo file
- sobel() - sobel magnitude edge finder,
- returns connected edges
- get_shape_mask() - gets segmented blob boundary and mask
- and shape features
- get_voxel_measures() - uses masks get object voxel moment
- and histogram features
- get_texture_measures() - uses masks get object 2D texture features
- """
- # get slice from the CT volume
- image = get_slice(filename)
- # need a copy of original image as filtering will occur on the extracted slice
- sourceImage = image.copy()
- # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform)
- # followed by connected component analysis. What is returned is labeled edges and the object list
- labeledMask, ROIList = sobel(image)
- # From the labeled edges and the object list get the labeled mask for each blob object
- get_shape_mask(labeledMask, ROIList)
- # Use the labeled mask and source image (raw) to get voxel features
- get_voxel_measures(sourceImage, labeledMask, ROIList)
- # Use the labeled mask and source image (raw) to get texture features
- get_texture_measures(sourceImage, labeledMask, ROIList)
- return sourceImage, labeledMask, ROIList
+ High level script calls Python functions:
+ get_slice() - a cardiac CT slice demo file
+ sobel() - sobel magnitude edge finder,
+ returns connected edges
+ get_shape_mask() - gets segmented blob boundary and mask
+ and shape features
+ get_voxel_measures() - uses masks get object voxel moment
+ and histogram features
+ get_texture_measures() - uses masks get object 2D texture features
+ """
+ # get slice from the CT volume
+ image = get_slice(filename)
+ # need a copy of original image as filtering will occur on the extracted slice
+ sourceImage = image.copy()
+ # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform)
+ # followed by connected component analysis. What is returned is labeled edges and the object list
+ labeledMask, ROIList = sobel(image)
+ # From the labeled edges and the object list get the labeled mask for each blob object
+ get_shape_mask(labeledMask, ROIList)
+ # Use the labeled mask and source image (raw) to get voxel features
+ get_voxel_measures(sourceImage, labeledMask, ROIList)
+ # Use the labeled mask and source image (raw) to get texture features
+ get_texture_measures(sourceImage, labeledMask, ROIList)
+ return sourceImage, labeledMask, ROIList
def grow_regions():
- """
- regionMask, numberRegions = region_grow()
- Inputs - No Input
- Outputs - regionMask, numberRegions
- - regionMask is the labeled segment masks from 2D image
- - numberRegions is the number of segmented blobs
+ """
+ regionMask, numberRegions = region_grow()
+ Inputs - No Input
+ Outputs - regionMask, numberRegions
+ - regionMask is the labeled segment masks from 2D image
+ - numberRegions is the number of segmented blobs
- High level script calls Python functions:
- get_slice() - a cardiac CT slice demo file
- region_grow() - "grows" connected blobs. default threshold
- and morphological filter structuring element
- """
- # get slice from the CT volume
- image = get_slice(filename)
- regionMask, numberRegions = region_grow(image)
- return regionMask, numberRegions
+ High level script calls Python functions:
+ get_slice() - a cardiac CT slice demo file
+ region_grow() - "grows" connected blobs. default threshold
+ and morphological filter structuring element
+ """
+ # get slice from the CT volume
+ image = get_slice(filename)
+ regionMask, numberRegions = region_grow(image)
+ return regionMask, numberRegions
def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7):
- """
- regionMask, numberRegions = region_grow(image, [defaults])
+ """
+ regionMask, numberRegions = region_grow(image, [defaults])
- Inputs - image, low_threshold, high_threshold, open, close
- - image is the numarray 2D image
- - low_ and high_ threshold are density values
- - open is open morphology structuring element
- odd size. 0 to turn off. max is 11
- - close is close morphology structuring element
- odd size. 0 to turn off. max is 11
+ Inputs - image, low_threshold, high_threshold, open, close
+ - image is the numarray 2D image
+ - low_ and high_ threshold are density values
+ - open is open morphology structuring element
+ odd size. 0 to turn off. max is 11
+ - close is close morphology structuring element
+ odd size. 0 to turn off. max is 11
- Outputs - regionMask, numberRegions
- - regionMask is the labeled segment masks from 2D image
- - numberRegions is the number of segmented blobs
- """
- # morphology filters need to be clipped to 11 max and be odd
- regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image)
- return regionMask, numberRegions
-
+ Outputs - regionMask, numberRegions
+ - regionMask is the labeled segment masks from 2D image
+ - numberRegions is the number of segmented blobs
+ """
+ # morphology filters need to be clipped to 11 max and be odd
+ regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image)
+ return regionMask, numberRegions
+
def get_slice(imageName='slice112.raw', bytes=2, rows=512, columns=512):
- # get a slice alrady extracted from the CT volume
- #image = open(imageName, 'rb')
- #slice = image.read(rows*columns*bytes)
- #values = struct.unpack('h'*rows*columns, slice)
- #ImageSlice = N.array(values, dtype=float).reshape(rows, columns)
+ # get a slice alrady extracted from the CT volume
+ #image = open(imageName, 'rb')
+ #slice = image.read(rows*columns*bytes)
+ #values = struct.unpack('h'*rows*columns, slice)
+ #ImageSlice = N.array(values, dtype=float).reshape(rows, columns)
- ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns);
+ ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns);
- # clip the ends for this test CT image file as the spine runs off the end of the image
- ImageSlice[505:512, :] = 0
- return (ImageSlice).astype(float)
+ # clip the ends for this test CT image file as the spine runs off the end of the image
+ ImageSlice[505:512, :] = 0
+ return (ImageSlice).astype(float)
def get_slice2(image_name='slice112.raw', bytes=2, shape=(512,512)):
- import mmap
- file = open(image_name, 'rb')
- mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)
- slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape)
- slice = slice.astype(float)
- slice[505:512,:] = 0
- return slice
+ import mmap
+ file = open(image_name, 'rb')
+ mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)
+ slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape)
+ slice = slice.astype(float)
+ slice[505:512,:] = 0
+ return slice
def save_slice(mySlice, filename='junk.raw', bytes=4):
- # just save the slice to a fixed file
- slice = mySlice.astype('u%d' % bytes)
- slice.tofile(filename)
+ # just save the slice to a fixed file
+ slice = mySlice.astype('u%d' % bytes)
+ slice.tofile(filename)
class TestSegment(NumpyTestCase):
def test1(self):
- image = get_slice(filename)
- sourceImage = image.copy()
- edges, objects = sobel(image)
- get_shape_mask(edges, objects)
- get_voxel_measures(sourceImage, edges, objects)
- get_texture_measures(sourceImage, edges, objects)
+ image = get_slice(filename)
+ sourceImage = image.copy()
+ edges, objects = sobel(image)
+ get_shape_mask(edges, objects)
+ get_voxel_measures(sourceImage, edges, objects)
+ get_texture_measures(sourceImage, edges, objects)
def test2(self):
- sourceImage, labeledMask, ROIList = segment_regions()
+ sourceImage, labeledMask, ROIList = segment_regions()
def test3(self):
- regionMask, numberRegions = grow_regions()
- regionMask.max()
- #save_slice(regionMask, 'regionMask.raw')
+ regionMask, numberRegions = grow_regions()
+ regionMask.max()
+ #save_slice(regionMask, 'regionMask.raw')
if __name__ == "__main__":
Modified: trunk/scipy/ndimage/segmenter.py
===================================================================
--- trunk/scipy/ndimage/segmenter.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/ndimage/segmenter.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -11,483 +11,483 @@
def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048,
highThreshold=600+2048, dust=16):
- """
- labeledEdges, ROIList = shen_castan(image, [default])
+ """
+ labeledEdges, ROIList = shen_castan(image, [default])
- implements Shen-Castan edge finding
+ implements Shen-Castan edge finding
- Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust
- - image is the numarray 2D image
- - IIR filter is filter parameter for exponential filter
- - shen_castan_low is edge threshold is range (0.0, 1.0]
- - window is search window for edge detection
- - low_ and high_ threshold are density values
- - dust is blob filter. blob area (length x width of bounding box) under this
- size threshold are filtered (referred to as dust and blown away)
+ Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust
+ - image is the numarray 2D image
+ - IIR filter is filter parameter for exponential filter
+ - shen_castan_low is edge threshold is range (0.0, 1.0]
+ - window is search window for edge detection
+ - low_ and high_ threshold are density values
+ - dust is blob filter. blob area (length x width of bounding box) under this
+ size threshold are filtered (referred to as dust and blown away)
- Outputs - labeledEdges, ROIList[>dust]
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList[>dust] is a blob feature list. Only values
- with bounding box area greater than dust threshold are returned
+ Outputs - labeledEdges, ROIList[>dust]
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList[>dust] is a blob feature list. Only values
+ with bounding box area greater than dust threshold are returned
- """
- labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window,
- lowThreshold, highThreshold, image)
- # allocated struct array for edge object measures. for now just the rect bounding box
- ROIList = N.zeros(numberObjects, dtype=S.objstruct)
- # return the bounding box for each connected edge
- S.get_object_stats(labeledEdges, ROIList)
- return labeledEdges, ROIList[ROIList['Area']>dust]
+ """
+ labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window,
+ lowThreshold, highThreshold, image)
+ # allocated struct array for edge object measures. for now just the rect bounding box
+ ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+ # return the bounding box for each connected edge
+ S.get_object_stats(labeledEdges, ROIList)
+ return labeledEdges, ROIList[ROIList['Area']>dust]
def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0,
apearture=21, dust=16):
- """
- labeledEdges, ROIList = sobel(image, [default])
+ """
+ labeledEdges, ROIList = sobel(image, [default])
- implements sobel magnitude edge finding
+ implements sobel magnitude edge finding
- Inputs - image, sobel_low, tMode, low_threshold, high_threshold,
- high_filter_cutoff, filter_aperature, dust
- - image is the numarray 2D image
- - sobel_low is edge threshold is range (0.0, 1.0]
- - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak)
- - low_ and high_ threshold are density values
- - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
- - aperature is odd filter kernel length
- - dust is blob filter. blob area (length x width of bounding box) under this
- size threshold are filtered (referred to as dust and blown away)
+ Inputs - image, sobel_low, tMode, low_threshold, high_threshold,
+ high_filter_cutoff, filter_aperature, dust
+ - image is the numarray 2D image
+ - sobel_low is edge threshold is range (0.0, 1.0]
+ - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak)
+ - low_ and high_ threshold are density values
+ - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
+ - aperature is odd filter kernel length
+ - dust is blob filter. blob area (length x width of bounding box) under this
+ size threshold are filtered (referred to as dust and blown away)
- Outputs - labeledEdges, ROIList[>dust]
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList[>dust] is a blob feature list. Only values
- with bounding box area greater than dust threshold are returned
+ Outputs - labeledEdges, ROIList[>dust]
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList[>dust] is a blob feature list. Only values
+ with bounding box area greater than dust threshold are returned
- """
- # get sobel edge points. return edges that are labeled (1..numberObjects)
- labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold,
- highThreshold, BPHigh, apearture, image)
- # allocated struct array for edge object measures. for now just the rect bounding box
- ROIList = N.zeros(numberObjects, dtype=S.objstruct)
- # return the bounding box for each connected edge
- S.get_object_stats(labeledEdges, ROIList)
- # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge'
- S.morpho_thin_filt(labeledEdges, ROIList)
- return labeledEdges, ROIList[ROIList['Area']>dust]
+ """
+ # get sobel edge points. return edges that are labeled (1..numberObjects)
+ labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold,
+ highThreshold, BPHigh, apearture, image)
+ # allocated struct array for edge object measures. for now just the rect bounding box
+ ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+ # return the bounding box for each connected edge
+ S.get_object_stats(labeledEdges, ROIList)
+ # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge'
+ S.morpho_thin_filt(labeledEdges, ROIList)
+ return labeledEdges, ROIList[ROIList['Area']>dust]
def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048,
highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16):
- """
- labeledEdges, ROIList = canny(image, [default])
+ """
+ labeledEdges, ROIList = canny(image, [default])
- implements canny edge finding
+ implements canny edge finding
- Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold,
- high_threshold, high_filter_cutoff, filter_aperature, dust
- - image is the numarray 2D image
- - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter
- - clow is low edge threshold is range (0.0, 1.0]
- - chigh is high edge threshold is range (0.0, 1.0]
- - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak)
- - low_ and high_ threshold are density values
- - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
- - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
- - aperature is odd filter kernel length
- - dust is blob filter. blob area (length x width of bounding box) under this
- size threshold are filtered (referred to as dust and blown away)
+ Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold,
+ high_threshold, high_filter_cutoff, filter_aperature, dust
+ - image is the numarray 2D image
+ - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter
+ - clow is low edge threshold is range (0.0, 1.0]
+ - chigh is high edge threshold is range (0.0, 1.0]
+ - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak)
+ - low_ and high_ threshold are density values
+ - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
+ - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0]
+ - aperature is odd filter kernel length
+ - dust is blob filter. blob area (length x width of bounding box) under this
+ size threshold are filtered (referred to as dust and blown away)
- Outputs - labeledEdges, ROIList[>dust]
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList[>dust] is a blob feature list. Only values
- with bounding box area greater than dust threshold are returned
+ Outputs - labeledEdges, ROIList[>dust]
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList[>dust] is a blob feature list. Only values
+ with bounding box area greater than dust threshold are returned
- """
- # get canny edge points. return edges that are labeled (1..numberObjects)
- labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold,
- BPHigh, apearture, image)
- # allocated struct array for edge object measures. for now just the rect bounding box
- ROIList = N.zeros(numberObjects, dtype=S.objstruct)
- # return the bounding box for each connected edge
- S.get_object_stats(labeledEdges, ROIList)
- return labeledEdges, ROIList[ROIList['Area']>dust]
+ """
+ # get canny edge points. return edges that are labeled (1..numberObjects)
+ labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold,
+ BPHigh, apearture, image)
+ # allocated struct array for edge object measures. for now just the rect bounding box
+ ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+ # return the bounding box for each connected edge
+ S.get_object_stats(labeledEdges, ROIList)
+ return labeledEdges, ROIList[ROIList['Area']>dust]
def get_shape_mask(labeledEdges, ROIList):
- """
- get_shape_mask(labeledEdges, ROIList)
+ """
+ get_shape_mask(labeledEdges, ROIList)
- takes labeled edge image plus ROIList (blob descriptors) and generates
- boundary shape features and builds labeled blob masks. 'labeledEdges'
- is over-written by 'labeledMask'. Adds features to ROIList structure
+ takes labeled edge image plus ROIList (blob descriptors) and generates
+ boundary shape features and builds labeled blob masks. 'labeledEdges'
+ is over-written by 'labeledMask'. Adds features to ROIList structure
- Inputs - labeledEdges, ROIList
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList is a blob feature list.
+ Inputs - labeledEdges, ROIList
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList is a blob feature list.
- Output - no return. edge image input is over-written with mask image.
- ROIList added to.
+ Output - no return. edge image input is over-written with mask image.
+ ROIList added to.
- """
+ """
- # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList
- # GetShapeMask will augment the ROI list
- # labeledEdges is the original edge image and overwritten as mask image
- # maskImage is the mask that is used for blob texture / pixel features
- S.build_boundary(labeledEdges, ROIList)
- return
+ # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList
+ # GetShapeMask will augment the ROI list
+ # labeledEdges is the original edge image and overwritten as mask image
+ # maskImage is the mask that is used for blob texture / pixel features
+ S.build_boundary(labeledEdges, ROIList)
+ return
def get_voxel_measures(rawImage, labeledEdges, ROIList):
- """
- get_voxel_measures(rawImage, labeledEdges, ROIList)
+ """
+ get_voxel_measures(rawImage, labeledEdges, ROIList)
- takes raw 2D image, labeled blob mask and ROIList. computes voxel features
- (moments, histogram) for each blob. Adds features to ROIList structure.
+ takes raw 2D image, labeled blob mask and ROIList. computes voxel features
+ (moments, histogram) for each blob. Adds features to ROIList structure.
- Inputs - rawImage, labeledEdges, ROIList
- - rawImage is the original source 2D image
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList is a blob feature list.
+ Inputs - rawImage, labeledEdges, ROIList
+ - rawImage is the original source 2D image
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList is a blob feature list.
- Output - no return. ROIList added to.
+ Output - no return. ROIList added to.
- """
- #
- # pass raw image, labeled mask and the partially filled ROIList
- # VoxelMeasures will fill the voxel features in the list
- #
- S.voxel_measures(rawImage, labeledEdges, ROIList)
- return
+ """
+ #
+ # pass raw image, labeled mask and the partially filled ROIList
+ # VoxelMeasures will fill the voxel features in the list
+ #
+ S.voxel_measures(rawImage, labeledEdges, ROIList)
+ return
def get_texture_measures(rawImage, labeledEdges, ROIList):
- """
- get_texture_measures(rawImage, labeledEdges, ROIList)
+ """
+ get_texture_measures(rawImage, labeledEdges, ROIList)
- takes raw 2D image, labeled blob mask and ROIList. computes 2D
- texture features using 7x7 Law's texture filters applied
- to segmented blobs. TEM (texture energy metric) is computed
- for each Law's filter image and stored in TEM part of ROIList.
+ takes raw 2D image, labeled blob mask and ROIList. computes 2D
+ texture features using 7x7 Law's texture filters applied
+ to segmented blobs. TEM (texture energy metric) is computed
+ for each Law's filter image and stored in TEM part of ROIList.
- Inputs - rawImage, labeledEdges, ROIList
- - rawImage is the original source 2D image
- - labeledEdges is boundary (edges) of segmented 'blobs',
- numerically labeled by blob number
- - ROIList is a blob feature list.
+ Inputs - rawImage, labeledEdges, ROIList
+ - rawImage is the original source 2D image
+ - labeledEdges is boundary (edges) of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList is a blob feature list.
- Output - no return. ROIList added to.
- """
- #
- # pass raw image, labeled mask and the partially filled ROIList
- # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list
- #
- S.texture_measures(rawImage, labeledEdges, ROIList)
- return
+ Output - no return. ROIList added to.
+ """
+ #
+ # pass raw image, labeled mask and the partially filled ROIList
+ # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list
+ #
+ S.texture_measures(rawImage, labeledEdges, ROIList)
+ return
def segment_regions():
- """
- sourceImage, labeledMask, ROIList = segment_regions()
+ """
+ sourceImage, labeledMask, ROIList = segment_regions()
- Inputs - No Input
+ Inputs - No Input
- Outputs - sourceImage, labeledMask, ROIList
- - sourceImage is raw 2D image (default cardiac CT slice for demo
- - labeledMask is mask of segmented 'blobs',
- numerically labeled by blob number
- - ROIList is numerical Python structure of intensity, shape and
- texture features for each blob
+ Outputs - sourceImage, labeledMask, ROIList
+ - sourceImage is raw 2D image (default cardiac CT slice for demo
+ - labeledMask is mask of segmented 'blobs',
+ numerically labeled by blob number
+ - ROIList is numerical Python structure of intensity, shape and
+ texture features for each blob
- High level script calls Python functions:
- get_slice() - a cardiac CT slice demo file
- sobel() - sobel magnitude edge finder,
- returns connected edges
- get_shape_mask() - gets segmented blob boundary and mask
- and shape features
- get_voxel_measures() - uses masks get object voxel moment
- and histogram features
- get_texture_measures() - uses masks get object 2D texture features
- """
- # get slice from the CT volume
- image = get_slice(filename)
- # need a copy of original image as filtering will occur on the extracted slice
- sourceImage = image.copy()
- # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform)
- # followed by connected component analysis. What is returned is labeled edges and the object list
- labeledMask, ROIList = sobel(image)
- # From the labeled edges and the object list get the labeled mask for each blob object
- get_shape_mask(labeledMask, ROIList)
- # Use the labeled mask and source image (raw) to get voxel features
- get_voxel_measures(sourceImage, labeledMask, ROIList)
- # Use the labeled mask and source image (raw) to get texture features
- get_texture_measures(sourceImage, labeledMask, ROIList)
- return sourceImage, labeledMask, ROIList
+ High level script calls Python functions:
+ get_slice() - a cardiac CT slice demo file
+ sobel() - sobel magnitude edge finder,
+ returns connected edges
+ get_shape_mask() - gets segmented blob boundary and mask
+ and shape features
+ get_voxel_measures() - uses masks get object voxel moment
+ and histogram features
+ get_texture_measures() - uses masks get object 2D texture features
+ """
+ # get slice from the CT volume
+ image = get_slice(filename)
+ # need a copy of original image as filtering will occur on the extracted slice
+ sourceImage = image.copy()
+ # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform)
+ # followed by connected component analysis. What is returned is labeled edges and the object list
+ labeledMask, ROIList = sobel(image)
+ # From the labeled edges and the object list get the labeled mask for each blob object
+ get_shape_mask(labeledMask, ROIList)
+ # Use the labeled mask and source image (raw) to get voxel features
+ get_voxel_measures(sourceImage, labeledMask, ROIList)
+ # Use the labeled mask and source image (raw) to get texture features
+ get_texture_measures(sourceImage, labeledMask, ROIList)
+ return sourceImage, labeledMask, ROIList
def grow_regions():
- """
- regionMask, numberRegions = region_grow()
- Inputs - No Input
- Outputs - regionMask, numberRegions
- - regionMask is the labeled segment masks from 2D image
- - numberRegions is the number of segmented blobs
+ """
+ regionMask, numberRegions = region_grow()
+ Inputs - No Input
+ Outputs - regionMask, numberRegions
+ - regionMask is the labeled segment masks from 2D image
+ - numberRegions is the number of segmented blobs
- High level script calls Python functions:
- get_slice() - a cardiac CT slice demo file
- region_grow() - "grows" connected blobs. default threshold
- and morphological filter structuring element
- """
- # get slice from the CT volume
- image = get_slice(filename)
- regionMask, numberRegions = region_grow(image)
- return regionMask, numberRegions
+ High level script calls Python functions:
+ get_slice() - a cardiac CT slice demo file
+ region_grow() - "grows" connected blobs. default threshold
+ and morphological filter structuring element
+ """
+ # get slice from the CT volume
+ image = get_slice(filename)
+ regionMask, numberRegions = region_grow(image)
+ return regionMask, numberRegions
def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7):
- """
- regionMask, numberRegions = region_grow(image, [defaults])
+ """
+ regionMask, numberRegions = region_grow(image, [defaults])
- Inputs - image, low_threshold, high_threshold, open, close
- - image is the numarray 2D image
- - low_ and high_ threshold are density values
- - open is open morphology structuring element
- odd size. 0 to turn off. max is 11
- - close is close morphology structuring element
- odd size. 0 to turn off. max is 11
+ Inputs - image, low_threshold, high_threshold, open, close
+ - image is the numarray 2D image
+ - low_ and high_ threshold are density values
+ - open is open morphology structuring element
+ odd size. 0 to turn off. max is 11
+ - close is close morphology structuring element
+ odd size. 0 to turn off. max is 11
- Outputs - regionMask, numberRegions
- - regionMask is the labeled segment masks from 2D image
- - numberRegions is the number of segmented blobs
- """
- # morphology filters need to be clipped to 11 max and be odd
- regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image)
- return regionMask, numberRegions
-
+ Outputs - regionMask, numberRegions
+ - regionMask is the labeled segment masks from 2D image
+ - numberRegions is the number of segmented blobs
+ """
+ # morphology filters need to be clipped to 11 max and be odd
+ regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image)
+ return regionMask, numberRegions
+
def get_slice(imageName='slice112.raw', bytes=2, rows=512, columns=512):
- # get a slice alrady extracted from the CT volume
- #image = open(imageName, 'rb')
- #slice = image.read(rows*columns*bytes)
- #values = struct.unpack('h'*rows*columns, slice)
- #ImageSlice = N.array(values, dtype=float).reshape(rows, columns)
+ # get a slice alrady extracted from the CT volume
+ #image = open(imageName, 'rb')
+ #slice = image.read(rows*columns*bytes)
+ #values = struct.unpack('h'*rows*columns, slice)
+ #ImageSlice = N.array(values, dtype=float).reshape(rows, columns)
- ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns);
+ ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns);
- # clip the ends for this test CT image file as the spine runs off the end of the image
- ImageSlice[505:512, :] = 0
- return (ImageSlice).astype(float)
+ # clip the ends for this test CT image file as the spine runs off the end of the image
+ ImageSlice[505:512, :] = 0
+ return (ImageSlice).astype(float)
def get_slice2(image_name='slice112.raw', bytes=2, shape=(512,512)):
- import mmap
- file = open(image_name, 'rb')
- mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)
- slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape)
- slice = slice.astype(float)
- # this is for the test CT as spine runs off back of image
- slice[505:512,:] = 0
- return slice
+ import mmap
+ file = open(image_name, 'rb')
+ mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)
+ slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape)
+ slice = slice.astype(float)
+ # this is for the test CT as spine runs off back of image
+ slice[505:512,:] = 0
+ return slice
def save_slice(mySlice, filename='junk.raw', bytes=4):
- # just save the slice to a fixed file
- slice = mySlice.astype('u%d' % bytes)
- slice.tofile(filename)
+ # just save the slice to a fixed file
+ slice = mySlice.astype('u%d' % bytes)
+ slice.tofile(filename)
def build_d_gauss_kernel(gWidth=21, sigma=1.0):
- """
- build the derivative of Gaussian kernel for Canny edge filter
- DGFilter = build_d_gauss_kernel(gWidth, sigma)
- Inputs:
- gWdith is width of derivative of Gaussian kernel
- sigma is sigma term of derivative of Gaussian kernel
- Output:
- DGFilter (a struct). Use in Canny filter call
+ """
+ build the derivative of Gaussian kernel for Canny edge filter
+ DGFilter = build_d_gauss_kernel(gWidth, sigma)
+ Inputs:
+ gWdith is width of derivative of Gaussian kernel
+ sigma is sigma term of derivative of Gaussian kernel
+ Output:
+ DGFilter (a struct). Use in Canny filter call
- """
- kernel = N.zeros((1+2*(gWidth-1)), dtype=float)
- indices = range(1, gWidth)
+ """
+ kernel = N.zeros((1+2*(gWidth-1)), dtype=float)
+ indices = range(1, gWidth)
- i = 0
- kernel[gWidth-1] = math.exp(((-i*i)/(2.0 * sigma * sigma)))
- kernel[gWidth-1] *= -(i / (sigma * sigma))
- for i in indices:
- kernel[gWidth-1+i] = math.exp(((-i*i)/(2.0 * sigma * sigma)))
- kernel[gWidth-1+i] *= -(i / (sigma * sigma))
- kernel[gWidth-1-i] = -kernel[gWidth-1+i]
+ i = 0
+ kernel[gWidth-1] = math.exp(((-i*i)/(2.0 * sigma * sigma)))
+ kernel[gWidth-1] *= -(i / (sigma * sigma))
+ for i in indices:
+ kernel[gWidth-1+i] = math.exp(((-i*i)/(2.0 * sigma * sigma)))
+ kernel[gWidth-1+i] *= -(i / (sigma * sigma))
+ kernel[gWidth-1-i] = -kernel[gWidth-1+i]
- DGFilter= {'kernelSize' : gWidth, 'coefficients': kernel}
+ DGFilter= {'kernelSize' : gWidth, 'coefficients': kernel}
- return DGFilter
+ return DGFilter
def build_2d_kernel(aperature=21, hiFilterCutoff=10.0):
- """
- build flat FIR filter with sinc kernel
- this is bandpass, but low cutoff is 0.0
- Use in Sobel and Canny filter edge find as image pre-process
+ """
+ build flat FIR filter with sinc kernel
+ this is bandpass, but low cutoff is 0.0
+ Use in Sobel and Canny filter edge find as image pre-process
- FIRFilter = build_2d_kernel(aperature, hiFilterCutoff)
- Inputs:
- aperature is number of FIR taps in sinc kernel
- hiFilterCutoff is digital frequency cutoff in range (0.0, 180.0)
- Output:
- FIRFilter (a struct)
+ FIRFilter = build_2d_kernel(aperature, hiFilterCutoff)
+ Inputs:
+ aperature is number of FIR taps in sinc kernel
+ hiFilterCutoff is digital frequency cutoff in range (0.0, 180.0)
+ Output:
+ FIRFilter (a struct)
- """
+ """
- rad = math.pi / 180.0
- HalfFilterTaps = (aperature-1) / 2
- kernel = N.zeros((aperature), dtype=N.float32)
- LC = 0.0
- HC = hiFilterCutoff * rad
- t2 = 2.0 * math.pi
- t1 = 2.0 * HalfFilterTaps + 1.0
- indices = range(-HalfFilterTaps, HalfFilterTaps+1, 1)
- j = 0
- for i in indices:
- if i == 0:
- tLOW = LC
- tHIGH = HC
- else:
- tLOW = math.sin(i*LC)/i
- tHIGH = math.sin(i*HC)/i
- # Hamming window
- t3 = 0.54 + 0.46*(math.cos(i*t2/t1))
- t4 = t3*(tHIGH-tLOW)
- kernel[j] = t4
- j += 1
+ rad = math.pi / 180.0
+ HalfFilterTaps = (aperature-1) / 2
+ kernel = N.zeros((aperature), dtype=N.float32)
+ LC = 0.0
+ HC = hiFilterCutoff * rad
+ t2 = 2.0 * math.pi
+ t1 = 2.0 * HalfFilterTaps + 1.0
+ indices = range(-HalfFilterTaps, HalfFilterTaps+1, 1)
+ j = 0
+ for i in indices:
+ if i == 0:
+ tLOW = LC
+ tHIGH = HC
+ else:
+ tLOW = math.sin(i*LC)/i
+ tHIGH = math.sin(i*HC)/i
+ # Hamming window
+ t3 = 0.54 + 0.46*(math.cos(i*t2/t1))
+ t4 = t3*(tHIGH-tLOW)
+ kernel[j] = t4
+ j += 1
- # normalize the kernel
- sum = kernel.sum()
- kernel /= sum
+ # normalize the kernel
+ sum = kernel.sum()
+ kernel /= sum
- FIRFilter= {'kernelSize' : aperature, 'coefficients': kernel}
+ FIRFilter= {'kernelSize' : aperature, 'coefficients': kernel}
- return FIRFilter
+ return FIRFilter
def build_laws_kernel():
- """
- build 6 length-7 Law's texture filter masks
- mask names are: 'L', 'S', 'E', 'W', 'R', 'O'
+ """
+ build 6 length-7 Law's texture filter masks
+ mask names are: 'L', 'S', 'E', 'W', 'R', 'O'
- LAWSFilter = build_laws_kernel()
+ LAWSFilter = build_laws_kernel()
- Inputs:
- None
+ Inputs:
+ None
- Output:
- LAWSFilter (a struct)
+ Output:
+ LAWSFilter (a struct)
- """
- aperature = (6, 7)
- coefficients = N.zeros((aperature), dtype=N.float32)
- names = ('L', 'E', 'S', 'W', 'R', 'O' )
+ """
+ aperature = (6, 7)
+ coefficients = N.zeros((aperature), dtype=N.float32)
+ names = ('L', 'E', 'S', 'W', 'R', 'O' )
- coefficients[0, :] = ( 1.0, 6.0, 15.0, 20.0, 15.0, 6.0, 1.0 )
- coefficients[1, :] = (-1.0, -4.0, -5.0, 0.0, 5.0, 4.0, 1.0 )
- coefficients[2, :] = (-1.0, -2.0, 1.0, 4.0, 1.0, -2.0, -1.0 )
- coefficients[3, :] = (-1.0, 0.0, 3.0, 0.0, -3.0, 0.0, 1.0 )
- coefficients[4, :] = ( 1.0, -2.0, -1.0, 4.0, -1.0, -2.0, 1.0 )
- coefficients[5, :] = (-1.0, 6.0, -15.0, 20.0, -15.0, 6.0, -1.0 )
+ coefficients[0, :] = ( 1.0, 6.0, 15.0, 20.0, 15.0, 6.0, 1.0 )
+ coefficients[1, :] = (-1.0, -4.0, -5.0, 0.0, 5.0, 4.0, 1.0 )
+ coefficients[2, :] = (-1.0, -2.0, 1.0, 4.0, 1.0, -2.0, -1.0 )
+ coefficients[3, :] = (-1.0, 0.0, 3.0, 0.0, -3.0, 0.0, 1.0 )
+ coefficients[4, :] = ( 1.0, -2.0, -1.0, 4.0, -1.0, -2.0, 1.0 )
+ coefficients[5, :] = (-1.0, 6.0, -15.0, 20.0, -15.0, 6.0, -1.0 )
- LAWSFilter= {'numKernels' : 6, 'kernelSize' : 7, 'coefficients': coefficients, 'names': names}
+ LAWSFilter= {'numKernels' : 6, 'kernelSize' : 7, 'coefficients': coefficients, 'names': names}
- return LAWSFilter
+ return LAWSFilter
def build_morpho_thin_masks():
- """
- build 2 sets (J and K) of 8 3x3 morphology masks (structuring elements)
- to implement thinning (medial axis transformation - MAT)
+ """
+ build 2 sets (J and K) of 8 3x3 morphology masks (structuring elements)
+ to implement thinning (medial axis transformation - MAT)
- MATFilter = build_morpho_thin_masks()
+ MATFilter = build_morpho_thin_masks()
- Inputs:
- None
+ Inputs:
+ None
- Output:
- MATFilter (a struct)
+ Output:
+ MATFilter (a struct)
- """
+ """
- # (layers, rows, cols)
- shape = (8, 3, 3)
- J_mask = N.zeros((shape), dtype=N.ushort)
- K_mask = N.zeros((shape), dtype=N.ushort)
+ # (layers, rows, cols)
+ shape = (8, 3, 3)
+ J_mask = N.zeros((shape), dtype=N.ushort)
+ K_mask = N.zeros((shape), dtype=N.ushort)
- # load the 8 J masks for medial axis transformation
- J_mask[0][0][0] = 1;
- J_mask[0][0][1] = 1;
- J_mask[0][0][2] = 1;
- J_mask[0][1][1] = 1;
+ # load the 8 J masks for medial axis transformation
+ J_mask[0][0][0] = 1;
+ J_mask[0][0][1] = 1;
+ J_mask[0][0][2] = 1;
+ J_mask[0][1][1] = 1;
- J_mask[1][0][1] = 1;
- J_mask[1][1][1] = 1;
- J_mask[1][1][2] = 1;
+ J_mask[1][0][1] = 1;
+ J_mask[1][1][1] = 1;
+ J_mask[1][1][2] = 1;
- J_mask[2][0][0] = 1;
- J_mask[2][1][0] = 1;
- J_mask[2][2][0] = 1;
- J_mask[2][1][1] = 1;
+ J_mask[2][0][0] = 1;
+ J_mask[2][1][0] = 1;
+ J_mask[2][2][0] = 1;
+ J_mask[2][1][1] = 1;
- J_mask[3][0][1] = 1;
- J_mask[3][1][0] = 1;
- J_mask[3][1][1] = 1;
+ J_mask[3][0][1] = 1;
+ J_mask[3][1][0] = 1;
+ J_mask[3][1][1] = 1;
- J_mask[4][0][2] = 1;
- J_mask[4][1][1] = 1;
- J_mask[4][1][2] = 1;
- J_mask[4][2][2] = 1;
+ J_mask[4][0][2] = 1;
+ J_mask[4][1][1] = 1;
+ J_mask[4][1][2] = 1;
+ J_mask[4][2][2] = 1;
- J_mask[5][1][0] = 1;
- J_mask[5][1][1] = 1;
- J_mask[5][2][1] = 1;
+ J_mask[5][1][0] = 1;
+ J_mask[5][1][1] = 1;
+ J_mask[5][2][1] = 1;
- J_mask[6][1][1] = 1;
- J_mask[6][2][0] = 1;
- J_mask[6][2][1] = 1;
- J_mask[6][2][2] = 1;
+ J_mask[6][1][1] = 1;
+ J_mask[6][2][0] = 1;
+ J_mask[6][2][1] = 1;
+ J_mask[6][2][2] = 1;
- J_mask[7][1][1] = 1;
- J_mask[7][1][2] = 1;
- J_mask[7][2][1] = 1;
+ J_mask[7][1][1] = 1;
+ J_mask[7][1][2] = 1;
+ J_mask[7][2][1] = 1;
- # load the 8 K masks for medial axis transformation
- K_mask[0][2][0] = 1;
- K_mask[0][2][1] = 1;
- K_mask[0][2][2] = 1;
+ # load the 8 K masks for medial axis transformation
+ K_mask[0][2][0] = 1;
+ K_mask[0][2][1] = 1;
+ K_mask[0][2][2] = 1;
- K_mask[1][1][0] = 1;
- K_mask[1][2][0] = 1;
- K_mask[1][2][1] = 1;
+ K_mask[1][1][0] = 1;
+ K_mask[1][2][0] = 1;
+ K_mask[1][2][1] = 1;
- K_mask[2][0][2] = 1;
- K_mask[2][1][2] = 1;
- K_mask[2][2][2] = 1;
+ K_mask[2][0][2] = 1;
+ K_mask[2][1][2] = 1;
+ K_mask[2][2][2] = 1;
- K_mask[3][1][2] = 1;
- K_mask[3][2][1] = 1;
- K_mask[3][2][2] = 1;
+ K_mask[3][1][2] = 1;
+ K_mask[3][2][1] = 1;
+ K_mask[3][2][2] = 1;
- K_mask[4][0][0] = 1;
- K_mask[4][1][0] = 1;
- K_mask[4][2][0] = 1;
+ K_mask[4][0][0] = 1;
+ K_mask[4][1][0] = 1;
+ K_mask[4][2][0] = 1;
- K_mask[5][0][1] = 1;
- K_mask[5][0][2] = 1;
- K_mask[5][1][2] = 1;
+ K_mask[5][0][1] = 1;
+ K_mask[5][0][2] = 1;
+ K_mask[5][1][2] = 1;
- K_mask[6][0][0] = 1;
- K_mask[6][0][1] = 1;
- K_mask[6][0][2] = 1;
+ K_mask[6][0][0] = 1;
+ K_mask[6][0][1] = 1;
+ K_mask[6][0][2] = 1;
- K_mask[7][0][0] = 1;
- K_mask[7][0][1] = 1;
- K_mask[7][1][0] = 1;
+ K_mask[7][0][0] = 1;
+ K_mask[7][0][1] = 1;
+ K_mask[7][1][0] = 1;
- MATFilter = {'number3x3Masks' : 8, 'jmask' : J_mask, 'kmask' : K_mask}
+ MATFilter = {'number3x3Masks' : 8, 'jmask' : J_mask, 'kmask' : K_mask}
- return MATFilter
+ return MATFilter
Modified: trunk/scipy/ndimage/tests/test_segment.py
===================================================================
--- trunk/scipy/ndimage/tests/test_segment.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/ndimage/tests/test_segment.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -10,132 +10,132 @@
def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16):
- labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image)
- # allocated struct array for edge object measures. for now just the rect bounding box
- ROIList = N.zeros(numberObjects, dtype=S.objstruct)
- # return the bounding box for each connected edge
- S.get_object_stats(labeledEdges, ROIList)
- return labeledEdges, ROIList[ROIList['Area']>dust]
+ labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image)
+ # allocated struct array for edge object measures. for now just the rect bounding box
+ ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+ # return the bounding box for each connected edge
+ S.get_object_stats(labeledEdges, ROIList)
+ return labeledEdges, ROIList[ROIList['Area']>dust]
def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16):
- # get sobel edge points. return edges that are labeled (1..numberObjects)
- labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image)
- # allocated struct array for edge object measures. for now just the rect bounding box
- ROIList = N.zeros(numberObjects, dtype=S.objstruct)
- # return the bounding box for each connected edge
- S.get_object_stats(labeledEdges, ROIList)
- # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge'
- S.morpho_thin_filt(labeledEdges, ROIList)
- return labeledEdges, ROIList[ROIList['Area']>dust]
+ # get sobel edge points. return edges that are labeled (1..numberObjects)
+ labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image)
+ # allocated struct array for edge object measures. for now just the rect bounding box
+ ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+ # return the bounding box for each connected edge
+ S.get_object_stats(labeledEdges, ROIList)
+ # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge'
+ S.morpho_thin_filt(labeledEdges, ROIList)
+ return labeledEdges, ROIList[ROIList['Area']>dust]
def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048,
BPHigh=10.0, apearture=21, dust=16):
- # get canny edge points. return edges that are labeled (1..numberObjects)
- labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold,
- BPHigh, apearture, image)
- # allocated struct array for edge object measures. for now just the rect bounding box
- ROIList = N.zeros(numberObjects, dtype=S.objstruct)
- # return the bounding box for each connected edge
- S.get_object_stats(labeledEdges, ROIList)
- return labeledEdges, ROIList[ROIList['Area']>dust]
+ # get canny edge points. return edges that are labeled (1..numberObjects)
+ labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold,
+ BPHigh, apearture, image)
+ # allocated struct array for edge object measures. for now just the rect bounding box
+ ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+ # return the bounding box for each connected edge
+ S.get_object_stats(labeledEdges, ROIList)
+ return labeledEdges, ROIList[ROIList['Area']>dust]
def get_shape_mask(labeledEdges, ROIList):
- # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList
- # GetShapeMask will augment the ROI list
- # labeledEdges is the original edge image and overwritten as mask image
- # maskImage is the mask that is used for blob texture / pixel features
- S.build_boundary(labeledEdges, ROIList)
- return
+ # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList
+ # GetShapeMask will augment the ROI list
+ # labeledEdges is the original edge image and overwritten as mask image
+ # maskImage is the mask that is used for blob texture / pixel features
+ S.build_boundary(labeledEdges, ROIList)
+ return
def get_voxel_measures(rawImage, labeledEdges, ROIList):
- #
- # pass raw image, labeled mask and the partially filled ROIList
- # VoxelMeasures will fill the voxel features in the list
- #
- S.voxel_measures(rawImage, labeledEdges, ROIList)
- return
+ #
+ # pass raw image, labeled mask and the partially filled ROIList
+ # VoxelMeasures will fill the voxel features in the list
+ #
+ S.voxel_measures(rawImage, labeledEdges, ROIList)
+ return
def get_texture_measures(rawImage, labeledEdges, ROIList):
- #
- # pass raw image, labeled mask and the partially filled ROIList
- # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list
- #
- S.texture_measures(rawImage, labeledEdges, ROIList)
- return
+ #
+ # pass raw image, labeled mask and the partially filled ROIList
+ # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list
+ #
+ S.texture_measures(rawImage, labeledEdges, ROIList)
+ return
def segment_regions():
- # get slice from the CT volume
- image = get_slice(filename)
- # need a copy of original image as filtering will occur on the extracted slice
- sourceImage = image.copy()
- # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform)
- # followed by connected component analysis. What is returned is labeled edges and the object list
- labeledMask, ROIList = sobel(image)
- # From the labeled edges and the object list get the labeled mask for each blob object
- get_shape_mask(labeledMask, ROIList)
- # Use the labeled mask and source image (raw) to get voxel features
- get_voxel_measures(sourceImage, labeledMask, ROIList)
- # Use the labeled mask and source image (raw) to get texture features
- get_texture_measures(sourceImage, labeledMask, ROIList)
- return sourceImage, labeledMask, ROIList
+ # get slice from the CT volume
+ image = get_slice(filename)
+ # need a copy of original image as filtering will occur on the extracted slice
+ sourceImage = image.copy()
+ # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform)
+ # followed by connected component analysis. What is returned is labeled edges and the object list
+ labeledMask, ROIList = sobel(image)
+ # From the labeled edges and the object list get the labeled mask for each blob object
+ get_shape_mask(labeledMask, ROIList)
+ # Use the labeled mask and source image (raw) to get voxel features
+ get_voxel_measures(sourceImage, labeledMask, ROIList)
+ # Use the labeled mask and source image (raw) to get texture features
+ get_texture_measures(sourceImage, labeledMask, ROIList)
+ return sourceImage, labeledMask, ROIList
def grow_regions():
- # get slice from the CT volume
- image = get_slice(filename)
- regionMask, numberRegions = region_grow(image)
- return regionMask, numberRegions
+ # get slice from the CT volume
+ image = get_slice(filename)
+ regionMask, numberRegions = region_grow(image)
+ return regionMask, numberRegions
def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7):
- # morphology filters need to be clipped to 11 max and be odd
- regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image)
- return regionMask, numberRegions
-
+ # morphology filters need to be clipped to 11 max and be odd
+ regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image)
+ return regionMask, numberRegions
+
def get_slice(imageName='junk.raw', bytes=2, rows=512, columns=512):
- # get a slice alrady extracted from the CT volume
- #image = open(imageName, 'rb')
- #slice = image.read(rows*columns*bytes)
- #values = struct.unpack('h'*rows*columns, slice)
- #ImageSlice = N.array(values, dtype=float).reshape(rows, columns)
+ # get a slice alrady extracted from the CT volume
+ #image = open(imageName, 'rb')
+ #slice = image.read(rows*columns*bytes)
+ #values = struct.unpack('h'*rows*columns, slice)
+ #ImageSlice = N.array(values, dtype=float).reshape(rows, columns)
- ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns);
+ ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns);
- # clip the ends for this test CT image file as the spine runs off the end of the image
- ImageSlice[505:512, :] = 0
- return (ImageSlice).astype(float)
+ # clip the ends for this test CT image file as the spine runs off the end of the image
+ ImageSlice[505:512, :] = 0
+ return (ImageSlice).astype(float)
def get_slice2(image_name='junk.raw', bytes=2, shape=(512,512)):
- import mmap
- file = open(image_name, 'rb')
- mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)
- slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape)
- slice = slice.astype(float)
- slice[505:512,:] = 0
- return slice
+ import mmap
+ file = open(image_name, 'rb')
+ mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)
+ slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape)
+ slice = slice.astype(float)
+ slice[505:512,:] = 0
+ return slice
def save_slice(mySlice, filename='junk.raw', bytes=4):
- # just save the slice to a fixed file
- slice = mySlice.astype('u%d' % bytes)
- slice.tofile(filename)
+ # just save the slice to a fixed file
+ slice = mySlice.astype('u%d' % bytes)
+ slice.tofile(filename)
class TestSegment(NumpyTestCase):
def test1(self):
- image = get_slice(filename)
- sourceImage = image.copy()
- edges, objects = sobel(image)
- get_shape_mask(edges, objects)
- get_voxel_measures(sourceImage, edges, objects)
- get_texture_measures(sourceImage, edges, objects)
+ image = get_slice(filename)
+ sourceImage = image.copy()
+ edges, objects = sobel(image)
+ get_shape_mask(edges, objects)
+ get_voxel_measures(sourceImage, edges, objects)
+ get_texture_measures(sourceImage, edges, objects)
def test2(self):
- sourceImage, labeledMask, ROIList = segment_regions()
+ sourceImage, labeledMask, ROIList = segment_regions()
def test3(self):
- regionMask, numberRegions = grow_regions()
- print regionMask.max()
- #save_slice(regionMask, 'regionMask.raw')
+ regionMask, numberRegions = grow_regions()
+ print regionMask.max()
+ #save_slice(regionMask, 'regionMask.raw')
if __name__ == "__main__":
Modified: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py
===================================================================
--- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -17,4 +17,3 @@
s = montecarlo.dictsampler(d)
for i in range(10):
temp = s.sample(10**7)
-
Modified: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py
===================================================================
--- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -8,4 +8,3 @@
s = montecarlo.dictsampler(d)
for i in range(10):
temp = s.sample(10**7)
-
Modified: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py
===================================================================
--- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -6,4 +6,3 @@
s = montecarlo.intsampler(v)
for i in range(10):
temp = s.sample(10**7)
-
Modified: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py
===================================================================
--- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -6,4 +6,3 @@
s = montecarlo.intsampler(v)
for i in range(10):
temp = s.sample(10**7)
-
Modified: trunk/scipy/sandbox/multigrid/adaptive.py
===================================================================
--- trunk/scipy/sandbox/multigrid/adaptive.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/multigrid/adaptive.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -139,8 +139,8 @@
max_levels = max_levels, \
max_coarse = max_coarse, \
mu = mu, epsilon = epsilon, \
- aggregation = aggregation )
-
+ aggregation = aggregation )
+
#create SA using x here
As,Ps,Ts,Bs = sa_hierarchy(A,x,AggOps)
@@ -160,7 +160,7 @@
for i in range(max_candidates):
B = B[:,1:]
As,Ps,Ts,Bs = sa_hierarchy(A,B,AggOps)
- x = self.__develop_new_candidate(As,Ps,Ts,Bs,AggOps,mu=mu)
+ x = self.__develop_new_candidate(As,Ps,Ts,Bs,AggOps,mu=mu)
B = hstack((B,x))
As,Ps,Ts,Bs = sa_hierarchy(A,B,AggOps)
@@ -174,7 +174,7 @@
max_coarse = 0
max_levels = len(aggregation) + 1
- # aSA parameters
+ # aSA parameters
# mu - number of test relaxation iterations
# epsilon - minimum acceptable relaxation convergence factor
@@ -307,7 +307,7 @@
aggregation = None
#A = poisson_problem2D(200,1e-2)
- #aggregation = [ sa_constant_interpolation(A*A*A,epsilon=0.0) ]
+ #aggregation = [ sa_constant_interpolation(A*A*A,epsilon=0.0) ]
#A = io.mmread("tests/sample_data/laplacian_41_3dcube.mtx").tocsr()
#A = io.mmread("laplacian_40_3dcube.mtx").tocsr()
@@ -373,7 +373,7 @@
pcolor(x.reshape(sqrt(len(x)),sqrt(len(x))))
show()
-
+
for c in asa.Bs[0].T:
#plot2d(c)
plot2d_arrows(c)
Modified: trunk/scipy/sandbox/multigrid/dec_test.py
===================================================================
--- trunk/scipy/sandbox/multigrid/dec_test.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/multigrid/dec_test.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -30,10 +30,10 @@
def curl_curl_prolongator(D_nodal,vertices):
if not isspmatrix_csr(D_nodal):
raise TypeError('expected csr_matrix')
-
+
A = D_nodal.T.tocsr() * D_nodal
aggs = multigridtools.sa_get_aggregates(A.shape[0],A.indptr,A.indices)
-
+
num_edges = D_nodal.shape[0]
num_basis = vertices.shape[1]
num_aggs = aggs.max() + 1
@@ -52,9 +52,9 @@
return coo_matrix((data,(row,col)),dims=(num_edges,num_basis*num_aggs)).tocsr()
-
+
def whitney_innerproduct_cache(cmplx,k):
h = hash(cmplx.vertices.tostring()) ^ hash(cmplx.simplices.tostring()) ^ hash(k)
@@ -102,33 +102,33 @@
Mi = whitney_innerproduct_cache(cmplx,i+1)
else:
Mi = regular_cube_innerproduct(cmplx,i+1)
-
-
+
+
dimension = mesh['vertices'].shape[1]
if True:
-
+
d0 = cmplx[0].d
d1 = cmplx[1].d
-
+
#A = (d1.T.tocsr() * d1 + d0 * d0.T.tocsr()).astype('d')
A = (d1.T.tocsr() * d1).astype('d')
-
+
P = curl_curl_prolongator(d0,mesh['vertices'])
-
+
num_blocks = P.shape[1]/dimension
blocks = arange(num_blocks).repeat(dimension)
-
+
P = sa_smoothed_prolongator(A,P,epsilon=0,omega=4.0/3.0)
-
+
PAP = P.T.tocsr() * A * P
-
+
candidates = None
candidates = zeros((num_blocks,dimension,dimension))
for n in range(dimension):
candidates[:,n,n] = 1.0
candidates = candidates.reshape(-1,dimension)
-
+
ml = smoothed_aggregation_solver(PAP,epsilon=0.0,candidates=candidates,blocks=blocks)
#A = PAP
ml = multilevel_solver([A] + ml.As, [P] + ml.Ps)
@@ -138,16 +138,16 @@
while len(bh) < 3:
bh.coarsen()
print repr(bh)
-
+
N = len(cochain_complex) - 1
-
+
B = bh[0][N - i].B
-
+
A = (B.T.tocsr() * B).astype('d')
#A = B.T.tocsr() * Mi * B
-
+
constant_prolongators = [lvl[N - i].I for lvl in bh[:-1]]
-
+
method = 'aSA'
if method == 'RS':
@@ -157,28 +157,28 @@
Ps.append( sa_smoothed_prolongator(As[-1],T,epsilon=0.0,omega=4.0/3.0) )
As.append(Ps[-1].T.tocsr() * As[-1] * Ps[-1])
ml = multilevel_solver(As,Ps)
-
+
else:
if method == 'BSA':
- if i == 0:
+ if i == 0:
candidates = None
else:
candidates = cmplx[0].d * mesh['vertices']
K = candidates.shape[1]
-
+
constant_prolongators = [constant_prolongators[0]] + \
[expand_into_blocks(T,K,1).tocsr() for T in constant_prolongators[1:] ]
ml = smoothed_aggregation_solver(A,candidates,aggregation=constant_prolongators)
elif method == 'aSA':
- asa = adaptive_sa_solver(A,aggregation=constant_prolongators,max_candidates=dimension,epsilon=0.0)
+ asa = adaptive_sa_solver(A,aggregation=constant_prolongators,max_candidates=dimension,epsilon=0.0)
ml = asa.solver
else:
raise ValuerError,'unknown method'
-
+
#ml = smoothed_aggregation_solver(A,candidates)
- #x = d0 * mesh['vertices'][:,0]
+ #x = d0 * mesh['vertices'][:,0]
x = rand(A.shape[0])
b = zeros_like(x)
#b = A*rand(A.shape[0])
Modified: trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py
===================================================================
--- trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -53,85 +53,84 @@
F_NODE = _multigridtools.F_NODE
def sa_get_aggregates(*args):
- """sa_get_aggregates(int n_row, int Ap, int Aj, std::vector<(int)> Bj)"""
- return _multigridtools.sa_get_aggregates(*args)
+ """sa_get_aggregates(int n_row, int Ap, int Aj, std::vector<(int)> Bj)"""
+ return _multigridtools.sa_get_aggregates(*args)
def rs_strong_connections(*args):
- """
- rs_strong_connections(int n_row, float theta, int Ap, int Aj, float Ax, std::vector<(int)> Sp,
- std::vector<(int)> Sj,
- std::vector<(float)> Sx)
- rs_strong_connections(int n_row, double theta, int Ap, int Aj, double Ax,
- std::vector<(int)> Sp, std::vector<(int)> Sj,
- std::vector<(double)> Sx)
"""
- return _multigridtools.rs_strong_connections(*args)
+ rs_strong_connections(int n_row, float theta, int Ap, int Aj, float Ax, std::vector<(int)> Sp,
+ std::vector<(int)> Sj,
+ std::vector<(float)> Sx)
+ rs_strong_connections(int n_row, double theta, int Ap, int Aj, double Ax,
+ std::vector<(int)> Sp, std::vector<(int)> Sj,
+ std::vector<(double)> Sx)
+ """
+ return _multigridtools.rs_strong_connections(*args)
def rs_interpolation(*args):
- """
- rs_interpolation(int n_nodes, int Ap, int Aj, float Ax, int Sp, int Sj,
- float Sx, int Tp, int Tj, float Tx, std::vector<(int)> Bp,
- std::vector<(int)> Bj, std::vector<(float)> Bx)
- rs_interpolation(int n_nodes, int Ap, int Aj, double Ax, int Sp, int Sj,
- double Sx, int Tp, int Tj, double Tx, std::vector<(int)> Bp,
- std::vector<(int)> Bj, std::vector<(double)> Bx)
"""
- return _multigridtools.rs_interpolation(*args)
+ rs_interpolation(int n_nodes, int Ap, int Aj, float Ax, int Sp, int Sj,
+ float Sx, int Tp, int Tj, float Tx, std::vector<(int)> Bp,
+ std::vector<(int)> Bj, std::vector<(float)> Bx)
+ rs_interpolation(int n_nodes, int Ap, int Aj, double Ax, int Sp, int Sj,
+ double Sx, int Tp, int Tj, double Tx, std::vector<(int)> Bp,
+ std::vector<(int)> Bj, std::vector<(double)> Bx)
+ """
+ return _multigridtools.rs_interpolation(*args)
def sa_strong_connections(*args):
- """
- sa_strong_connections(int n_row, float epsilon, int Ap, int Aj, float Ax,
- std::vector<(int)> Sp, std::vector<(int)> Sj,
- std::vector<(float)> Sx)
- sa_strong_connections(int n_row, double epsilon, int Ap, int Aj, double Ax,
- std::vector<(int)> Sp, std::vector<(int)> Sj,
- std::vector<(double)> Sx)
"""
- return _multigridtools.sa_strong_connections(*args)
+ sa_strong_connections(int n_row, float epsilon, int Ap, int Aj, float Ax,
+ std::vector<(int)> Sp, std::vector<(int)> Sj,
+ std::vector<(float)> Sx)
+ sa_strong_connections(int n_row, double epsilon, int Ap, int Aj, double Ax,
+ std::vector<(int)> Sp, std::vector<(int)> Sj,
+ std::vector<(double)> Sx)
+ """
+ return _multigridtools.sa_strong_connections(*args)
def sa_smoother(*args):
- """
- sa_smoother(int n_row, float omega, int Ap, int Aj, float Ax, int Sp,
- int Sj, float Sx, std::vector<(int)> Bp,
- std::vector<(int)> Bj, std::vector<(float)> Bx)
- sa_smoother(int n_row, double omega, int Ap, int Aj, double Ax,
- int Sp, int Sj, double Sx, std::vector<(int)> Bp,
- std::vector<(int)> Bj, std::vector<(double)> Bx)
"""
- return _multigridtools.sa_smoother(*args)
+ sa_smoother(int n_row, float omega, int Ap, int Aj, float Ax, int Sp,
+ int Sj, float Sx, std::vector<(int)> Bp,
+ std::vector<(int)> Bj, std::vector<(float)> Bx)
+ sa_smoother(int n_row, double omega, int Ap, int Aj, double Ax,
+ int Sp, int Sj, double Sx, std::vector<(int)> Bp,
+ std::vector<(int)> Bj, std::vector<(double)> Bx)
+ """
+ return _multigridtools.sa_smoother(*args)
def gauss_seidel(*args):
- """
- gauss_seidel(int n_row, int Ap, int Aj, float Ax, float x, float b,
- int row_start, int row_stop, int row_step)
- gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b,
- int row_start, int row_stop, int row_step)
- gauss_seidel(long long n_row, long long Ap, long long Aj, float Ax,
- float x, float b, long long row_start, long long row_stop,
- long long row_step)
- gauss_seidel(long long n_row, long long Ap, long long Aj, double Ax,
- double x, double b, long long row_start,
- long long row_stop, long long row_step)
"""
- return _multigridtools.gauss_seidel(*args)
+ gauss_seidel(int n_row, int Ap, int Aj, float Ax, float x, float b,
+ int row_start, int row_stop, int row_step)
+ gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b,
+ int row_start, int row_stop, int row_step)
+ gauss_seidel(long long n_row, long long Ap, long long Aj, float Ax,
+ float x, float b, long long row_start, long long row_stop,
+ long long row_step)
+ gauss_seidel(long long n_row, long long Ap, long long Aj, double Ax,
+ double x, double b, long long row_start,
+ long long row_stop, long long row_step)
+ """
+ return _multigridtools.gauss_seidel(*args)
def jacobi(*args):
- """
- jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b,
- float temp, int row_start, int row_stop,
- int row_step, float omega)
- jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b,
- double temp, int row_start, int row_stop,
- int row_step, double omega)
- jacobi(long long n_row, long long Ap, long long Aj, float Ax,
- float x, float b, float temp, long long row_start,
- long long row_stop, long long row_step,
- float omega)
- jacobi(long long n_row, long long Ap, long long Aj, double Ax,
- double x, double b, double temp, long long row_start,
- long long row_stop, long long row_step,
- double omega)
"""
- return _multigridtools.jacobi(*args)
-
+ jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b,
+ float temp, int row_start, int row_stop,
+ int row_step, float omega)
+ jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b,
+ double temp, int row_start, int row_stop,
+ int row_step, double omega)
+ jacobi(long long n_row, long long Ap, long long Aj, float Ax,
+ float x, float b, float temp, long long row_start,
+ long long row_stop, long long row_step,
+ float omega)
+ jacobi(long long n_row, long long Ap, long long Aj, double Ax,
+ double x, double b, double temp, long long row_start,
+ long long row_stop, long long row_step,
+ double omega)
+ """
+ return _multigridtools.jacobi(*args)
Modified: trunk/scipy/sandbox/multigrid/multilevel.py
===================================================================
--- trunk/scipy/sandbox/multigrid/multilevel.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/multigrid/multilevel.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -43,7 +43,7 @@
References:
"Multigrid"
- Trottenberg, U., C. W. Oosterlee, and Anton Schuller.
+ Trottenberg, U., C. W. Oosterlee, and Anton Schuller.
San Diego: Academic Press, 2001.
Appendix A
@@ -60,9 +60,9 @@
Ps.append(P)
return multilevel_solver(As,Ps)
-
+
def smoothed_aggregation_solver(A, B=None, blocks=None, \
aggregation=None, max_levels=10, \
max_coarse=500, epsilon=0.0, \
@@ -98,12 +98,12 @@
Strength of connection parameter used in aggregation.
omega: {float} : default 4.0/3.0
Damping parameter used in prolongator smoothing (0 < omega < 2)
- symmetric: {boolean} : default True
+ symmetric: {boolean} : default True
True if A is symmetric, False otherwise
rescale: {boolean} : default True
If True, symmetrically rescale A by the diagonal
i.e. A -> D * A * D, where D is diag(A)^-0.5
-
+
*Example*:
TODO
@@ -120,17 +120,17 @@
B = asarray(B)
pre,post = None,None #preprocess/postprocess
-
+
if rescale:
D_sqrt,D_sqrt_inv,A = symmetric_rescaling(A)
D_sqrt,D_sqrt_inv = diag_sparse(D_sqrt),diag_sparse(D_sqrt_inv)
-
+
B = D_sqrt * B #scale candidates
def pre(x,b):
return D_sqrt*x,D_sqrt_inv*b
def post(x):
return D_sqrt_inv*x
-
+
As = [A]
Ps = []
Modified: trunk/scipy/sandbox/multigrid/tests/test_utils.py
===================================================================
--- trunk/scipy/sandbox/multigrid/tests/test_utils.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/multigrid/tests/test_utils.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -59,7 +59,7 @@
cases = []
cases.append( diag_sparse(array([1,2,3,4])) )
cases.append( diag_sparse(array([1,0,3,4])) )
-
+
A = array([ [ 5.5, 3.5, 4.8],
[ 2. , 9.9, 0.5],
[ 6.5, 2.6, 5.7]])
Modified: trunk/scipy/sandbox/multigrid/utils.py
===================================================================
--- trunk/scipy/sandbox/multigrid/utils.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sandbox/multigrid/utils.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -61,11 +61,11 @@
D_sqrt = sqrt(D)
D_sqrt_inv = 1.0/D_sqrt
D_sqrt_inv[mask] = 0
-
+
#TODO time this against simple implementation
data = A.data * D_sqrt_inv[A.indices]
data *= D_sqrt_inv[arange(A.shape[0]).repeat(diff(A.indptr))]
-
+
DAD = A.__class__((data,A.indices,A.indptr),dims=A.shape)
return D_sqrt,D_sqrt_inv,DAD
Modified: trunk/scipy/sparse/sparse.py
===================================================================
--- trunk/scipy/sparse/sparse.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sparse/sparse.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -92,7 +92,7 @@
def set_shape(self,shape):
shape = tuple(shape)
-
+
if len(shape) != 2:
raise ValueError("Only two-dimensional sparse arrays "
"are supported.")
@@ -103,7 +103,7 @@
if not (shape[0] >= 1 and shape[1] >= 1):
raise TypeError,'invalid shape'
-
+
if (self._shape != shape) and (self._shape is not None):
try:
self = self.reshape(shape)
@@ -518,17 +518,17 @@
def _set_self(self, other, copy=False):
"""take the member variables of other and assign them to self"""
-
+
if copy:
other = other.copy()
-
+
self.data = other.data
self.indices = other.indices
self.indptr = other.indptr
self.shape = other.shape
self.dtype = other.data.dtype
-
+
def _check_format(self, orientation, full_check):
# some functions pass floats
self.shape = tuple([int(x) for x in self.shape])
@@ -988,14 +988,14 @@
self._set_self( other )
else:
- raise ValueError, "unrecognized form for csc_matrix constructor"
+ raise ValueError, "unrecognized form for csc_matrix constructor"
# Read matrix dimensions given, if any
if dims is not None:
self.shape = dims # spmatrix will check for errors
else:
- if self.shape is None:
+ if self.shape is None:
# shape not already set, try to infer dimensions
try:
M = self.indices.max() + 1
@@ -1238,7 +1238,7 @@
if copy:
arg1 = arg1.copy()
self._set_self( self._tothis(arg1) )
-
+
elif isinstance(arg1, tuple):
if isshape(arg1):
# It's a tuple of matrix dimensions (M, N)
@@ -1270,7 +1270,7 @@
other = coo_matrix((data, ij), dims=dims )
other = self._tothis(other)
self._set_self( other )
-
+
else:
raise ValueError, "unrecognized form for csr_matrix constructor"
@@ -1278,7 +1278,7 @@
if dims is not None:
self.shape = dims # spmatrix will check for errors
else:
- if self.shape is None:
+ if self.shape is None:
# shape not already set, try to infer dimensions
try:
M = len(self.indptr) - 1
Modified: trunk/scipy/sparse/sparsetools/sparsetools.py
===================================================================
--- trunk/scipy/sparse/sparsetools/sparsetools.py 2007-11-17 01:15:06 UTC (rev 3547)
+++ trunk/scipy/sparse/sparsetools/sparsetools.py 2007-11-19 04:13:22 UTC (rev 3548)
@@ -51,1609 +51,1608 @@
def extract_csr_diagonal(*args):
- """
- extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax,
- std::vector<(signed char)> Yx)
- extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax,
- std::vector<(unsigned char)> Yx)
- extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx)
- extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx)
- extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax,
- std::vector<(long long)> Yx)
- extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx)
- extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx)
- extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax,
- std::vector<(npy_cfloat_wrapper)> Yx)
- extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax,
- std::vector<(npy_cdouble_wrapper)> Yx)
- extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- signed char Ax, std::vector<(signed char)> Yx)
- extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- unsigned char Ax, std::vector<(unsigned char)> Yx)
- extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- short Ax, std::vector<(short)> Yx)
- extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- int Ax, std::vector<(int)> Yx)
- extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- long long Ax, std::vector<(long long)> Yx)
- extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- float Ax, std::vector<(float)> Yx)
- extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- double Ax, std::vector<(double)> Yx)
- extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx)
- extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx)
"""
- return _sparsetools.extract_csr_diagonal(*args)
+ extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax,
+ std::vector<(signed char)> Yx)
+ extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax,
+ std::vector<(unsigned char)> Yx)
+ extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx)
+ extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx)
+ extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax,
+ std::vector<(long long)> Yx)
+ extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx)
+ extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx)
+ extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax,
+ std::vector<(npy_cfloat_wrapper)> Yx)
+ extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax,
+ std::vector<(npy_cdouble_wrapper)> Yx)
+ extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ signed char Ax, std::vector<(signed char)> Yx)
+ extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ unsigned char Ax, std::vector<(unsigned char)> Yx)
+ extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ short Ax, std::vector<(short)> Yx)
+ extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ int Ax, std::vector<(int)> Yx)
+ extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ long long Ax, std::vector<(long long)> Yx)
+ extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ float Ax, std::vector<(float)> Yx)
+ extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ double Ax, std::vector<(double)> Yx)
+ extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx)
+ extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx)
+ """
+ return _sparsetools.extract_csr_diagonal(*args)
def extract_csc_diagonal(*args):
- """
- extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax,
- std::vector<(signed char)> Yx)
- extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax,
- std::vector<(unsigned char)> Yx)
- extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx)
- extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx)
- extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax,
- std::vector<(long long)> Yx)
- extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx)
- extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx)
- extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax,
- std::vector<(npy_cfloat_wrapper)> Yx)
- extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax,
- std::vector<(npy_cdouble_wrapper)> Yx)
- extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- signed char Ax, std::vector<(signed char)> Yx)
- extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- unsigned char Ax, std::vector<(unsigned char)> Yx)
- extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- short Ax, std::vector<(short)> Yx)
- extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- int Ax, std::vector<(int)> Yx)
- extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- long long Ax, std::vector<(long long)> Yx)
- extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- float Ax, std::vector<(float)> Yx)
- extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- double Ax, std::vector<(double)> Yx)
- extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx)
- extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
- npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx)
"""
- return _sparsetools.extract_csc_diagonal(*args)
+ extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax,
+ std::vector<(signed char)> Yx)
+ extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax,
+ std::vector<(unsigned char)> Yx)
+ extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx)
+ extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx)
+ extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax,
+ std::vector<(long long)> Yx)
+ extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx)
+ extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx)
+ extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax,
+ std::vector<(npy_cfloat_wrapper)> Yx)
+ extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax,
+ std::vector<(npy_cdouble_wrapper)> Yx)
+ extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ signed char Ax, std::vector<(signed char)> Yx)
+ extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ unsigned char Ax, std::vector<(unsigned char)> Yx)
+ extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ short Ax, std::vector<(short)> Yx)
+ extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ int Ax, std::vector<(int)> Yx)
+ extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ long long Ax, std::vector<(long long)> Yx)
+ extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ float Ax, std::vector<(float)> Yx)
+ extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ double Ax, std::vector<(double)> Yx)
+ extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx)
+ extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj,
+ npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx)
+ """
+ return _sparsetools.extract_csc_diagonal(*args)
def csrtocsc(*args):
- """
- csrtocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bi,
- std::vector<(signed char)> Bx)
- csrtocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bi,
- std::vector<(unsigned char)> Bx)
- csrtocsc(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bp,
- std::vector<(int)> Bi, std::vector<(short)> Bx)
- csrtocsc(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bp,
- std::vector<(int)> Bi, std::vector<(int)> Bx)
- csrtocsc(int n_row, int n_col, int Ap, int Aj, long long Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bi,
- std::vector<(long long)> Bx)
- csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp,
- std::vector<(int)> Bi, std::vector<(float)> Bx)
- csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp,
- std::vector<(int)> Bi, std::vector<(double)> Bx)
- csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bi,
- std::vector<(npy_cfloat_wrapper)> Bx)
- csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bi,
- std::vector<(npy_cdouble_wrapper)> Bx)
- csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
- signed char Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bi, std::vector<(signed char)> Bx)
- csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
- unsigned char Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bi, std::vector<(unsigned char)> Bx)
- csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
- short Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bi, std::vector<(short)> Bx)
- csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
- int Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bi, std::vector<(int)> Bx)
- csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
- long long Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bi, std::vector<(long long)> Bx)
- csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
- float Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bi, std::vector<(float)> Bx)
- csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
- double Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bi, std::vector<(double)> Bx)
- csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
- npy_cfloat_wrapper Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bi,
- std::vector<(npy_cfloat_wrapper)> Bx)
- csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
- npy_cdouble_wrapper Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bi,
- std::vector<(npy_cdouble_wrapper)> Bx)
"""
- return _sparsetools.csrtocsc(*args)
+ csrtocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bi,
+ std::vector<(signed char)> Bx)
+ csrtocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bi,
+ std::vector<(unsigned char)> Bx)
+ csrtocsc(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bp,
+ std::vector<(int)> Bi, std::vector<(short)> Bx)
+ csrtocsc(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bp,
+ std::vector<(int)> Bi, std::vector<(int)> Bx)
+ csrtocsc(int n_row, int n_col, int Ap, int Aj, long long Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bi,
+ std::vector<(long long)> Bx)
+ csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp,
+ std::vector<(int)> Bi, std::vector<(float)> Bx)
+ csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp,
+ std::vector<(int)> Bi, std::vector<(double)> Bx)
+ csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bi,
+ std::vector<(npy_cfloat_wrapper)> Bx)
+ csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bi,
+ std::vector<(npy_cdouble_wrapper)> Bx)
+ csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
+ signed char Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bi, std::vector<(signed char)> Bx)
+ csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
+ unsigned char Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bi, std::vector<(unsigned char)> Bx)
+ csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
+ short Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bi, std::vector<(short)> Bx)
+ csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
+ int Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bi, std::vector<(int)> Bx)
+ csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
+ long long Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bi, std::vector<(long long)> Bx)
+ csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
+ float Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bi, std::vector<(float)> Bx)
+ csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
+ double Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bi, std::vector<(double)> Bx)
+ csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
+ npy_cfloat_wrapper Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bi,
+ std::vector<(npy_cfloat_wrapper)> Bx)
+ csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj,
+ npy_cdouble_wrapper Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bi,
+ std::vector<(npy_cdouble_wrapper)> Bx)
+ """
+ return _sparsetools.csrtocsc(*args)
def csctocsr(*args):
- """
- csctocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bj,
- std::vector<(signed char)> Bx)
- csctocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bj,
- std::vector<(unsigned char)> Bx)
- csctocsr(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bp,
- std::vector<(int)> Bj, std::vector<(short)> Bx)
- csctocsr(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bp,
- std::vector<(int)> Bj, std::vector<(int)> Bx)
- csctocsr(int n_row, int n_col, int Ap, int Ai, long long Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bj,
- std::vector<(long long)> Bx)
- csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp,
- std::vector<(int)> Bj, std::vector<(float)> Bx)
- csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp,
- std::vector<(int)> Bj, std::vector<(double)> Bx)
- csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bj,
- std::vector<(npy_cfloat_wrapper)> Bx)
- csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax,
- std::vector<(int)> Bp, std::vector<(int)> Bj,
- std::vector<(npy_cdouble_wrapper)> Bx)
- csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
- signed char Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bj, std::vector<(signed char)> Bx)
- csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
- unsigned char Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx)
- csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
- short Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bj, std::vector<(short)> Bx)
- csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
- int Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bj, std::vector<(int)> Bx)
- csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
- long long Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bj, std::vector<(long long)> Bx)
- csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
- float Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bj, std::vector<(float)> Bx)
- csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
- double Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bj, std::vector<(double)> Bx)
- csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
- npy_cfloat_wrapper Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bj,
- std::vector<(npy_cfloat_wrapper)> Bx)
- csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
- npy_cdouble_wrapper Ax, std::vector<(long long)> Bp,
- std::vector<(long long)> Bj,
- std::vector<(npy_cdouble_wrapper)> Bx)
"""
- return _sparsetools.csctocsr(*args)
+ csctocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bj,
+ std::vector<(signed char)> Bx)
+ csctocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bj,
+ std::vector<(unsigned char)> Bx)
+ csctocsr(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bp,
+ std::vector<(int)> Bj, std::vector<(short)> Bx)
+ csctocsr(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bp,
+ std::vector<(int)> Bj, std::vector<(int)> Bx)
+ csctocsr(int n_row, int n_col, int Ap, int Ai, long long Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bj,
+ std::vector<(long long)> Bx)
+ csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp,
+ std::vector<(int)> Bj, std::vector<(float)> Bx)
+ csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp,
+ std::vector<(int)> Bj, std::vector<(double)> Bx)
+ csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bj,
+ std::vector<(npy_cfloat_wrapper)> Bx)
+ csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax,
+ std::vector<(int)> Bp, std::vector<(int)> Bj,
+ std::vector<(npy_cdouble_wrapper)> Bx)
+ csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
+ signed char Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bj, std::vector<(signed char)> Bx)
+ csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
+ unsigned char Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx)
+ csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
+ short Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bj, std::vector<(short)> Bx)
+ csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
+ int Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bj, std::vector<(int)> Bx)
+ csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
+ long long Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bj, std::vector<(long long)> Bx)
+ csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
+ float Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bj, std::vector<(float)> Bx)
+ csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
+ double Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bj, std::vector<(double)> Bx)
+ csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
+ npy_cfloat_wrapper Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bj,
+ std::vector<(npy_cfloat_wrapper)> Bx)
+ csctocsr(long long n_row, long long n_col, long long Ap, long long Ai,
+ npy_cdouble_wrapper Ax, std::vector<(long long)> Bp,
+ std::vector<(long long)> Bj,
+ std::vector<(npy_cdouble_wrapper)> Bx)
+ """
+ return _sparsetools.csctocsr(*args)
def csrtocoo(*args):
- """
- csrtocoo(int n_row, int n_col, int Ap, int Aj, signed char Ax,
- std::vector<(int)> Bi, std::vector<(int)> Bj,
- std::vector<(signed char)> Bx)
- csrtocoo(int n_row, int n_col, int Ap, int Aj, unsigned char Ax,
- std::vector<(int)> Bi, std::vector<(int)> Bj,
- std::vector<(unsigned char)> Bx)
- csrtocoo(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bi,
- std::vector<(int)> Bj, std::vector<(short)> Bx)
- csrtocoo(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bi,
- std::vector<(int)> Bj, std::vector<(int)> Bx)
- csrtocoo(int n_row, int n_col, int Ap, int Aj, long long Ax,
- std::vector<(int)> Bi, std::vector<(int)> Bj,
- std::vector<(long long)> Bx)
- csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi,
- std::vector<(int)> Bj, std::vector<(float)> Bx)
- csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi,
- std::vector<(int)> Bj, std::vector<(double)> Bx)
- csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax,
- std::vector<(int)> Bi, std::vector<(int)> Bj,
- std::vector<(npy_cfloat_wrapper)> Bx)
- csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax,
- std::vector<(int)> Bi, std::vector<(int)> Bj,
- std::vector<(npy_cdouble_wrapper)> Bx)
- csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
- signed char Ax, std::vector<(long long)> Bi,
- std::vector<(long long)> Bj, std::vector<(signed char)> Bx)
- csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
- unsigned char Ax, std::vector<(long long)> Bi,
- std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx)
- csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
- short Ax, std::vector<(long long)> Bi,
- std::vector<(long long)> Bj, std::vector<(short)> Bx)
- csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
- int Ax, std::vector<(long long)> Bi,
- std::vector<(long long)> Bj, std::vector<(int)> Bx)
- csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
- long long Ax, std::vector<(long long)> Bi,
- std::vector<(long long)> Bj, std::vector<(long long)> Bx)
- csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
- float Ax, std::vector<(long long)> Bi,
- std::vector<(long long)> Bj, std::vector<(float)> Bx)
- csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
- double Ax, std::vector<(long long)> Bi,
- std::vector<(long long)> Bj, std::vector<(double)> Bx)
- csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
- npy_cfloat_wrapper Ax, std::vector<(long long)> Bi,
- std::vector<(long long)> Bj,
- std::vector<(npy_cfloat_wrapper)> Bx)
- csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
- npy_cdouble_wrapper Ax, std::vector<(long long)> Bi,
- std::vector<(long long)> Bj,
- std::vector<(npy_cdouble_wrapper)> Bx)
"""
- return _sparsetools.csrtocoo(*args)
+ csrtocoo(int n_row, int n_col, int Ap, int Aj, signed char Ax,
+ std::vector<(int)> Bi, std::vector<(int)> Bj,
+ std::vector<(signed char)> Bx)
+ csrtocoo(int n_row, int n_col, int Ap, int Aj, unsigned char Ax,
+ std::vector<(int)> Bi, std::vector<(int)> Bj,
+ std::vector<(unsigned char)> Bx)
+ csrtocoo(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bi,
+ std::vector<(int)> Bj, std::vector<(short)> Bx)
+ csrtocoo(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bi,
+ std::vector<(int)> Bj, std::vector<(int)> Bx)
+ csrtocoo(int n_row, int n_col, int Ap, int Aj, long long Ax,
+ std::vector<(int)> Bi, std::vector<(int)> Bj,
+ std::vector<(long long)> Bx)
+ csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi,
+ std::vector<(int)> Bj, std::vector<(float)> Bx)
+ csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi,
+ std::vector<(int)> Bj, std::vector<(double)> Bx)
+ csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax,
+ std::vector<(int)> Bi, std::vector<(int)> Bj,
+ std::vector<(npy_cfloat_wrapper)> Bx)
+ csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax,
+ std::vector<(int)> Bi, std::vector<(int)> Bj,
+ std::vector<(npy_cdouble_wrapper)> Bx)
+ csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj,
+ signed char Ax, std::vector<(long long)> Bi,
+ std::vector<(long long)> Bj, std::vector<(signed char)> Bx)
+ csrtocoo(long long n_row, long long n_co