/* 16 July 1999 */ GO_EROS():=block ( print("ELEMENTARY ROW OPERATIONS", "Copyright 1999 by Laurence I. Gould, University of Hartford"), print("[You may force program termination using the Interrupt button.]"), print("CAUTIONS: Do not enter any symbol followed by a % except where asked.", "For example, x% is to be avoided."), START%, kill(EX%,NAME%,R%,C%,COR%,CORR%,X%,RI%,RF%,K%), print("INSTRUCTIONS: ", "Enter either m% for multiplying a row by some constant,", "or i% for interchanging two rows,", "or ma% for multiplying a row by some constant and adding the result to another row."), CORR%: read("Have you already generated a matrix, plus its name, as input?", "(type y for Yes or n for No) "), if CORR%=n then go(L_AA%), NAME%: read("Enter the name you gave to the matrix: "), R%: mat_nrows(NAME%), C%: mat_ncols(NAME%), if CORR%=y then go (L_AAA%), L_AA%, NAME%: read("Enter the name of the matrix (e.g., m): "), R%: read("Enter the number of rows: "), C%: read("Enter the number of columns: "), NAME%: entermatrix(R%,C%), L_AAA%, print(NAME%), COR%: read("Is this correct (y for Yes, n for No)? "), if COR%=n then go(START%), L_A%, X%: read("Enter either m% or i% or ma% : "), if X%#m% and X%#i% and X%#ma% then go(L_A%), L_E1%, RI%: read("Enter the starting row number: "), if integerp(RI%)=false or RI%>R% or RI%<1 then (print("Error!"), go(L_E1%)), if X%=m% then go(L_B%), L_E2%, RF%: read("Enter the ending row number: "), if integerp(RF%)=false or RF%>R% or RF%<1 then (print("Error!"), go(L_E2%)), L_B%, if X%=m% or X%=ma% then (K%: read("Enter the constant which multiplies the starting row: "), if X%=m% then print(NAME%:set_element(NAME%,RI%,K%*row(NAME%,RI%))) else if X%=ma% then print(NAME%:set_element(NAME%,RF%, K%*row(NAME%,RI%)+row(NAME%,RF%))) ), if X%=i% then (CNAME%:copymatrix(NAME%), for i : 1 step 1 thru C% do (CNAME%[RI%,i]:NAME%[RF%,i],CNAME%[RF%,i]:NAME%[RI%,i]), NAME%:copymatrix(CNAME%), remvalue(CNAME%), print(NAME%) ), /* for Macsyma 2.3 or higher one can use instead if X%=i% then print(NAME%:swap_rows(NAME%,RI%,RF%)), */ ST%: read("Start with a new matrix (y for Yes, n for No, or e to Exit)? "), if ST%=y then go(START%) else if ST%=n then go(L_A%) else return(END%(NAME%)) )$ END%(NAME%):=(print("***Program Terminated***"), print("Your final matrix, recalled by typing m, is"), print(m:NAME%) )$ save("eros.lsp",GO_EROS,END%)$