# Naming variables in a loop [closed]

I have this problem: Lets say i have an matrix A and use A.gram_schmidt() on it. then i get a matrix B whose rows are orthogonal. So what do i do now if i want use the vectors of the rows. How can i make them to variables practical? I tried this:

O, t = A.gram_schmidt()
for i in range(n):
wi = O.row(i)


But clearly this doesnt work, because sage doesnt identiy the "i" in "wi"...

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by bruno171092 close date 2015-12-23 09:20:25.216696

Sort by ยป oldest newest most voted

It is not of very good practice to use variable names that depend on indices. And in practice this is hard to manipulate. You can alternatively do

sage: O, t =  A.gram_schmidt()
sage: w = O.rows()
sage: w[0]
-> the first row
sage: w[1]
-> the second row


But since you have the function O.row available I do not see why you need to make variables out of it.

more

## Stats

Asked: 2015-12-23 07:27:45 -0600

Seen: 26 times

Last updated: Dec 23 '15