File: sarag_initialization.mac

package info (click to toggle)
maxima 5.42.1-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 150,192 kB
  • sloc: lisp: 382,565; fortran: 14,666; perl: 14,365; tcl: 11,123; sh: 4,622; makefile: 2,688; ansic: 444; xml: 23; awk: 17; sed: 17
file content (42 lines) | stat: -rw-r--r-- 899 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* It makes the linear solver non-verbose */
linsolvewarn : false;

/* Necessary to use "lcm" */
/*load("functs"); */

/* Fix for the wrong redefinition of "evenp" and "oddp" */
/* introduced in Maxima 5.9.3-3 */
/* evenp(i) := is(mod(i,2)=0); */
/* oddp(i) := is(mod(i,2)=1); */

/* 
lcm(a,b) := ratexpand(a*b/gcd(a,b));
*/

lst_gcd(lst) := 
  if length(lst) = 1 then 
    lst[1]
  else
    if length(lst) = 2 then
      pair_gcd(lst[1],lst[2])
    else
      lst_gcd(cons(pair_gcd(lst[1],lst[2]),rest(lst,2)));

pair_gcd(lhs,rhs) := gcd(lhs,rhs); /* just to avoid name conflicts */

pair_lcm(lhs,rhs) := ratexpand((lhs*rhs)/pair_gcd(lhs,rhs));


lst_lcm(lst) := 
  if length(lst) = 1 then
    lst[1]
  else
    if length(lst) = 2 then
      pair_lcm(lst[1],lst[2])
    else
      lst_lcm(cons(pair_lcm(lst[1],lst[2]),rest(lst,2)));

lcm([lst]) := lst_lcm(lst);

sarag_lcm([lst]) := lst_lcm(lst);