0

I am looking to implement what I think is best approximated as a doubly linked list. It is actually three matrices where pointers can point from cell to cell between matrices. Here is an example of what it looks like graphically. enter image description here Right now I have the actual values (M, Ix, Iy) as numpy arrays. I was thinking of storing the pointers as numpy chararrays, but it still seems kludgy particularly since I will have to store two characters, one to represent parent array and the other to represent the direction.

If there is no easy way to directly point to the memory address of these numpy positions (but I'm not set on that, an earlier implementation was a dict and I considered lists for a while) what is the best way to represent these 'pointers'?

John La Rooy
  • 295,403
  • 53
  • 369
  • 502
Ian Fiddes
  • 2,821
  • 5
  • 29
  • 49
  • Can you give us an example of how you plan to use this structure? – Hugh Bothwell Nov 22 '13 at 02:02
  • 1
    @HughBothwell Based on the context of the matrix, it's probably the Smith Waterman algorithm. – Dan Nov 22 '13 at 02:03
  • @Dan: interesting! After some quick reading: I'd sidestep the whole question and write a wrapper for FASTA or CUDASW++ instead; could expect probably a 500x or more speedup. – Hugh Bothwell Nov 22 '13 at 02:16
  • I haven't got a numpy specific answer, but it's worth noting that python list variables are references. `a = [1,2,3]` followed by `b=a` does not create two lists. – Dan Nov 22 '13 at 02:23
  • Yes, it is a implementation of the smith-waterman (with affine gaps). I do understand that python is by reference, and that this is roughly analogous to pointers, but I think in the case where you are trying to store a reference to a specific member of a list it falls short. – Ian Fiddes Nov 22 '13 at 02:49
  • Does http://stackoverflow.com/a/18117034/2530083 help at all? – rtrwalker Nov 22 '13 at 05:08

0 Answers0