Hi Jason - thanks a lot - I have attached a text file which is just a
cleaned-up version of my code, with some explanations at the top for
functions whose details are not relevant to the question. Apologies -
you'll see it's a "neat mess", so to speak ....

Kind regards

Gary


On Sat, Mar 30, 2013 at 10:45 AM, Jason Grout
<jason-s...@creativetrax.com>wrote:

> On 3/30/13 5:08 AM, Gary McConnell wrote:
>
>> Hi Jason
>>
>> fair question - I was trying to avoid including all the boring details
>> of my code! In the simplest case I have a search routine which looks for
>> M sets of d vectors inside a vector space of dimension N over a finite
>> field, whose dot products satisfy a bunch of polynomial equations. My
>> problem is that I need to compare each new vector with all of the
>> antecedent vectors, so that the number of "equations" varies with d, M
>> and N (in several "recursive dimensions"). The only way I have been able
>> to do it so far is to construct separate loops by hand for each of d,N,M
>> and for each "new" vector within them ... ie every time I alter any one
>> of d, N or M, I need a new program!!
>>
>> So I had hoped that your code would have allowed me to "telescope" the
>> search and comparison loops as functions of d,M,N in a neat way; only
>> obviously I've misunderstood what it does.
>>
>
> I think the confusion may be in what we mean by "variable".  My code in
> this thread is for easily constructing Sage symbolic variables, and is just
> a convenient way to do something like var('x1,x2,x3') (x[1] is something
> like var('x1')).  It sounds like you are referring to python variables,
> which are a different concept.
>
> Still, if you can give a short example illustrating exactly what you
> trying to do, I think we can still probably point you in the right
> direction (for example, give us a working example of the nested for loops
> that you currently have that you'd like to generalize).  If I followed you
> correctly, you should be able to do what you want fairly easily.
>
>
> Thanks,
>
> Jason
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sage-support" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/**
> topic/sage-support/**GFJdjFvKCvo/unsubscribe?hl=en<https://groups.google.com/d/topic/sage-support/GFJdjFvKCvo/unsubscribe?hl=en>
> .
> To unsubscribe from this group and all its topics, send an email to
> sage-support+unsubscribe@**googlegroups.com<sage-support%2bunsubscr...@googlegroups.com>
> .
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/sage-support?hl=en<http://groups.google.com/group/sage-support?hl=en>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


# ip(v,w) = dot product of vectors
# xRy(v,w) = is x related to y by the conditions I need?
# XRY(V,W) = are all v in V and w in W pairwise related by xRy? (where V and W 
are lists of vectors)


N1 = list(#of all of the vectors i am interested in#); n1 = len(N1);
for vv1 in range(0,n1):
    for vv2 in range(0,n1):
        if ip(N1[vv1],N1[vv2])==0:
            for vv3 in range(0,n1):
                if ip(N1[vv1],N1[vv3])==0 and ip(N1[vv2],N1[vv3])==0:
                    basez1 = list([N1[vv1],N1[vv2],N1[vv3]]);
                    print basez1; print vv1,vv2,vv3; print 
'basez1...................\n';
                    for ww1 in range(0,n1):
                        if xRy(N1[ww1],N1[vv1]) and xRy(N1[ww1],N1[vv2]) and 
xRy(N1[ww1],N1[vv3]):
                            for ww2 in range(0,n1):
                                if ip(N1[ww1],N1[ww2])==0:
                                    if xRy(N1[ww2],N1[vv1]) and 
xRy(N1[ww2],N1[vv2]) and xRy(N1[ww2],N1[vv3]):
                                        for ww3 in range(0,n1):
                                            if ip(N1[ww1],N1[ww3])==0 and 
ip(N1[ww2],N1[ww3])==0:
                                                if xRy(N1[ww3],N1[vv1]) and 
xRy(N1[ww3],N1[vv2]) and xRy(N1[ww3],N1[vv3]):
                                                    testbasez2 = 
list([N1[ww1],N1[ww2],N1[ww3]]);
                                                    if XRY(basez1,testbasez2):
                                                        basez2 = testbasez2;
                                                        print basez2; print 
ww1,ww2,ww3; print 'basez2-------------------\n';
                                                        for xx1 in range(0,n1):
                                                            if 
xRy(N1[xx1],N1[vv1]) and xRy(N1[xx1],N1[vv2]) and xRy(N1[xx1],N1[vv3]) and 
xRy(N1[xx1],N1[ww1]) and xRy(N1[xx1],N1[ww2]) and xRy(N1[xx1],N1[ww3]):
                                                                    for xx2 in 
range(0,n1):
                                                                        if 
ip(N1[xx1],N1[xx2])==0:
                                                                            if 
xRy(N1[xx2],N1[vv1]) and xRy(N1[xx2],N1[vv2]) and xRy(N1[xx2],N1[vv3]) and 
xRy(N1[xx2],N1[ww1]) and xRy(N1[xx2],N1[ww2]) and xRy(N1[xx2],N1[ww3]):
                                                                                
for xx3 in range(0,n1):
                                                                                
    if ip(N1[xx1],N1[xx3])==0 and ip(N1[xx2],N1[xx3])==0:
                                                                                
        if xRy(N1[xx3],N1[vv1]) and xRy(N1[xx3],N1[vv2]) and 
xRy(N1[xx3],N1[vv3]) and xRy(N1[xx3],N1[ww1]) and xRy(N1[xx3],N1[ww2]) and 
xRy(N1[xx3],N1[ww3]):
                                                                                
            testbasez3 = list([N1[xx1],N1[xx2],N1[xx3]]);
                                                                                
            if XRY(basez1,testbasez3) and XRY(basez2,testbasez3):
                                                                                
                basez3 = testbasez3;
                                                                                
                print basez3; print xx1,xx2,xx3; print 
'basez3=====================\n';

Reply via email to