/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- Complex
- set
- getReal
- getImag
- scaleUp
- scaleDown
- plus
- sub
- plus
- sub
package jp.ac.nime.computer.grpsimulator.ImgPr;
/** •¡‘f”‚ð•\‚·’PƒƒNƒ‰ƒX
* @author Kikuchi
*/
public class Complex {
protected double re_; // ®”•”
protected double im_; // ‹•”•”
/** ƒRƒ“ƒXƒgƒ‰ƒNƒ^
*/
public Complex() {
set(0.0, 0.0);
}
/** ƒRƒ“ƒXƒgƒ‰ƒNƒ^
* @param r ®”•”
* @param i ‹•”•”
*/
public Complex(double r, double i) {
set(r, i);
}
/** ’l‚̃Zƒbƒg
* @param r ®”•”
* @param i ‹•”•”
*/
public void set(double r, double i) {
re_ = r;
im_ = i;
}
/** ®”•”Žæ“¾
* @return ®”•”
*/
public double getReal() {
return re_;
}
/** ‹•”•”Žæ“¾
* @return ‹•”•”
*/
public double getImag() {
return im_;
}
/** Šg‘å
* @param a ‚©‚¯‚é”
*/
public void scaleUp(double a) {
re_ *= a;
im_ *= a;
}
/** k¬
* @param a Š„‚é”
*/
public void scaleDown(double a) {
re_ /= a;
im_ /= a;
}
/** Ž©g‚ɉÁŽZ
* @param a —v‘fA
*/
public void plus(Complex a) {
re_ += a.re_;
im_ += a.im_;
}
/** Ž©g‚ðŒ¸ŽZ
* @param a —v‘fA
*/
public void sub(Complex a) {
re_ -= a.re_;
im_ -= a.im_;
}
/** ‰ÁŽZ a + b
* @param a —v‘fA
* @param b —v‘fB
*/
public static Complex plus(Complex a, Complex b) {
return new Complex(a.re_ + b.re_, a.im_ + b.im_);
}
/** Œ¸ŽZ a - b
* @param a —v‘fA
* @param b —v‘fB
*/
public static Complex sub(Complex a, Complex b) {
return new Complex(a.re_ - b.re_, a.im_ - b.im_);
}
}