Matrices in Maxima

1

I need to perform a function that generates the next type of matrix. For more information about this type of matrix, link I would like the link, the L_4.

I have the definition in Python, which is the language I know the most:

def pascal_upp(n):
    s = [[0] * n for _ in range(n)]
    s[0] = [1] * n
    for i in range(1, n):
        for j in range(i, n):
            s[i][j] = s[i-1][j-1] + s[i][j-1]
    return s

def pascal_low(n):
    # transpose of pascal_upp(n)
    return [list(x) for x in zip(*pascal_upp(n))]

I also have the function that generates Pascal's triangle in Maxima

sjoin(v, j) := apply(sconcat, rest(join(makelist(j, length(v)), v)))$

display_pascal_triangle(n) := for i from 0 thru n do disp(sjoin(makelist(binomial(i, j), j, 0, i), " "));

Actually, I need to perform the pascal_low(n) function in Maxima, but I do not know how you can implement definitions with matrices in this language. I have made the definition in Python, because I see that they are similar languages. I hope you can help me.

What I want is the program that does the following:

pascal_low(4);


                                [ 1  0  0  0 ]
                                [ 1  1  0  0 ]
(%o7)                           [ 1  2  1  0 ]
                                [ 1  3  3  1 ]
    
asked by aprendiendo-a-programar 09.03.2018 в 18:28
source

0 answers