Hello. I'm new to SymPy.

I am trying to implement an algorithm in Python for merging Bezier
curves from this paper:
http://cg.cs.tsinghua.edu.cn/~shimin/pdf/cad%202001_merging.pdf and in
it (after spending quite some time in understanding the mathematics,
as I am actually a humanities scholar) I have come to the point of
implementing the system of linear equations represented by eqn (15).

The implementation *seems* quite straightforward:

    from sympy import Matrix
    A = zeros ( n + 1 , n + 1 ) # n+1, since we need to iterate 0 to n
    B = zeros ( n + 1, 1 )
    for i in range ( n + 1 ) : # 0 to n
        B [ i ] = ( DeltaP [ i ] [ n - i ] - ( mu ** i ) * DeltaQ [ i
] [ 0 ] ) * 2
        for l in range ( n + 1 ) : # 0 to n
            A [ i, l ] = ( 1 + ( - mu ) ** ( l + i ) ) * binomCoeff ( l + i, i )
    X = A . LUsolve ( B )

(where DeltaP, DeltaQ and binomCoeff are appropriately defined
previously in my program).

However it seems that I cannot create a Matrix with any arbitrary
value type. Since I'm using PyQt for other things I chose QPointF, but
that doesn't seem to be permitted since I can't even do:

B=Matrix(2,2,[QPointF(1,1),QPointF(2,2),QPointF(3,0),QPointF(4,-1)])

as I get the error:

B=Matrix(2,2,[QPointF(1,1),QPointF(2,2),QPointF(3,0),QPointF(4,-1)])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/sympy/matrices/matrices.py",
line 104, in __init__
    self.mat = map(lambda i: sympify(i), mat)
  File "/usr/lib/python2.7/dist-packages/sympy/matrices/matrices.py",
line 104, in <lambda>
    self.mat = map(lambda i: sympify(i), mat)
  File "/usr/lib/python2.7/dist-packages/sympy/core/sympify.py", line
155, in sympify
    expr = parse_expr(a, locals or {}, rational, convert_xor)
  File "/usr/lib/python2.7/dist-packages/sympy/parsing/sympy_parser.py",
line 111, in parse_expr
    expr = eval(code, global_dict, local_dict) # take local objects in
preference
  File "<string>", line 1, in <module>
AttributeError: 'Symbol' object has no attribute 'Symbol'

I can convert the QPointF to a pair-tuple if that is acceptable, but I
am not so sure it's mathematically OK to convert it to a complex pair
i.e. x + iy (since the complex multiplication might have side effects
when sympy is trying to find the conjugate matrix in the process of
find inv(A) ???).

Any guidance you people can provide in this regard would be most
appreciated. Thank you!

-- 
Shriramana Sharma

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to