Changeset 3562


Ignore:
Timestamp:
09/02/03 20:02:44 (19 years ago)
Author:
piso
Message:

multiplyBy()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Complex.java

    r3534 r3562  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: Complex.java,v 1.12 2003-08-26 17:17:35 piso Exp $
     5 * $Id: Complex.java,v 1.13 2003-09-02 20:02:44 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    125125    }
    126126
     127    public LispObject multiplyBy(LispObject obj) throws LispError
     128    {
     129        if (obj instanceof Complex) {
     130            LispObject a = realpart;
     131            LispObject b = imagpart;
     132            LispObject c = ((Complex)obj).getRealPart();
     133            LispObject d = ((Complex)obj).getImaginaryPart();
     134            LispObject ac = a.multiplyBy(c);
     135            LispObject bd = b.multiplyBy(d);
     136            return Complex.getInstance(ac.subtract(bd),
     137                                       a.add(b).multiplyBy(c.add(d)).subtract(ac).subtract(bd));
     138        }
     139        return Complex.getInstance(realpart.multiplyBy(obj),
     140                                   imagpart.multiplyBy(obj));
     141    }
     142
    127143    public boolean isEqualTo(LispObject obj) throws LispError
    128144    {
Note: See TracChangeset for help on using the changeset viewer.