[Insight-users] Factors

Kevin H. Hobbs hobbsk at ohiou.edu
Mon Oct 19 14:59:54 EDT 2009


On Mon, 2009-10-19 at 14:01 -0400, Luis Ibanez wrote:
> Hi Kevin,
> 
> Could this code do the trick ?:
> http://forums.devarticles.com/c-c-help-52/c-calculating-prime-factors-15530.html
> 
> It's about 30 lines of code...

Well, yes. I didn't give that page enough of a read mostly because the
question specifically wanted a way to get rid of the multiplicity of the
factors, also I want to make sure that tricks like only searching up to
sqrt(n) are employed, and I was hoping there was some builtin function
of a library that is already in ITK like std, vnl, or boost that had a
prototype like:

int number_found = prime_factors( 
	int * returned_factors, 
	const int number_to_be_factored );

Where I could be reasonably sure that the library did the factoring
correctly.

The idea was that if I had a 100 by 120 by 70 image and I wanted 180
pieces. The region splitter would factor 180 into [2 2 3 3 5] which is
more factors than dimensions so it would multiply the least two factors
together until it had three of them or [4 5 9]. Then assign them to the
dimensions by size [5 9 4]. Finally produce sub-regions that are 20 by
(13 or 14) by (17 or 18) 

This idea is on the back burner though as I just decided to get on with
writing an implementation of Tugurlan's MPI Fast marching where I
pretend I don't know anything at all about the shape of the pieces or
how many neighbors a piece has, and just find the intersection of each
piece with every other, and the ones where GetNumberOfPixels != 0 are my
neighbors.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091019/c020968c/attachment-0001.pgp>


More information about the Insight-users mailing list