亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? complex1.java

?? java與模式隨書源碼,作者閻宏博士,包括書中各個設計模式的實現,沒有密碼,
?? JAVA
字號:
package com.javapatterns.immutable.complex;

final public class Complex1 extends Number
		implements java.io.Serializable, Cloneable, Comparable
{
	/**	
	 *	The imaginary unit.
	 */
	static final public Complex1 i = new Complex1(0.0, 1.0);

	/**	
	 *	 Real part of the Complex.
	 */
	private double re;

	/**
	 *	 Imaginary part of the Complex.
	 */
	private double im;

	/**
	 *  String used in converting Complex to String.
	 */
	public static String suffix = "i";
	

	/** 
	 *	Constructs a Complex equal to the argument.
	 *	@param	z	A Complex object
	 *			If z is null then a NullPointerException is thrown.
	 */
	public Complex1(Complex1 z)
	{
		re = z.re;
		im = z.im;
	}


	/** 
	 *	Constructs a Complex with real and imaginary parts given
	 *	by the input arguments.
	 *	@param	re	A double value equal to the real part of the Complex object.
	 *	@param	im	A double value equal to the imaginary part of the Complex object.
	 */
	public Complex1(double re, double im)
	{
		this.re = re;
		this.im = im;
	}


	/** 
	 *	Constructs a Complex with a zero imaginary part. 
	 *	@param	re	A double value equal to the real part of the Complex object.
	 */
	public Complex1(double re)
	{
		this.re = re;
		this.im = 0.0;
	}


	/**
	 *	Constructs a Complex equal to zero.
	 */
	public Complex1()
	{
		re = 0.0;
		im = 0.0;
	}
	
	/**
	 *	Compares with another Complex. 
     *	<p><em>Note: To be useful in hashtables this method
     *	considers two NaN double values to be equal. This
     *	is not according to IEEE specification.</em>
	 *	@param	z	A Complex object.
	 *	@return True if the real and imaginary parts of this object
	 *			are equal to their counterparts in the argument; false, otherwise.
	 */
	public boolean equals(Complex1 z)
	{
		return (re == z.re  &&  im == z.im);
	}

   
	/**
     *	Compares this object against the specified object.
     *	@param	obj	The object to compare with.
     *	@return True if the objects are the same; false otherwise.
     */
    public boolean equals(Object obj)
	{
		if (obj == null)
        {
			return false;
		}
        else if (obj instanceof Complex)
        {
			return equals((Complex)obj);
		}
        else
        {
			return false;
		}
	}

    /**
     *	Returns a hashcode for this Complex.
     *	@return  A hash code value for this object. 
     */
    public int hashCode()
	{
		long re_bits = Double.doubleToLongBits(re);
		long im_bits = Double.doubleToLongBits(im);
		return (int)((re_bits^im_bits)^((re_bits^im_bits)>>32));
    }	 

	/**
	 *	Returns the value of the real part as a short. 
	 */
	public short shortValue() 
	{
		return (short)re;
	}

	/**
	 *	Returns the real part of a Complex object. 
	 *	@return	The real part of z.
	 */
	public double real()
	{
		return re;
	}

	/** 
	 *	Returns the imaginary part of a Complex object. 
	 *	@param	z	A Complex object.
	 *	@return	The imaginary part of z.
	 */
	public double imag()
	{
		return im;
	}

 	/**
	 *	Returns the value of the real part as an int. 
	 */
	public int intValue() 
	{
		return (int)re;
	}

	/** 
	 *	Returns the value of the real part as a byte. 
	 */
	public byte byteValue()
	{
		return (byte)re;
	}

	/**
	 *	Returns the value of the real part as a long. 
	 */
	public long longValue() 
	{
		return (long)re;
	}

	/**
	 *	Returns the value of the real part as a float. 
	 */       
	public float floatValue()
	{
		return (float)re;
	}

	/**
	 *	Returns the value of the real part as a double. 
	 */
	public double doubleValue()
	{
		return re;
	}

	/**
	 *	Compares this Complex to another Object. If the Object is a Complex,
	 *	this function behaves like compareTo(Complex). Otherwise, it throws
	 *	a ClassCastException (as Complex objects are comparable only to other
	 *	Complex objects).
	 */
	public int compareTo(Object obj)
	{
		return compareTo((Complex)obj);
	}

	/**
	 *	Compares two Complex objects.
	 *	<P>A lexagraphical ordering is used. First the real parts are compared
	 *	in the sense of Double.compareTo. If the real parts are unequal this
	 *	is the return value. If the return parts are equal then the comparison
	 *	of the imaginary parts is returned.
	 *	@return		The value 0 if z is  equal to this Complex;
	 *				a value less than 0 if this Complex is less than z;
	 *				and a value greater than 0 if this Complex is greater
	 *				than z.
	 */
	public int compareTo(Complex1 z)
	{
		int	compare = new Double(re).compareTo(new Double(z.re));
		if (compare == 0)
        {
			compare = new Double(im).compareTo(new Double(z.im));
		}
		return compare;
	}

	/** 
	 *	Returns the real part of a Complex object. 
	 *	@param	z	A Complex object.
	 *	@return	The real part of z.
	 */
	public static double real(Complex1 z)
	{
		return z.re;
	}

	/** 
	 *	Returns the imaginary part of a Complex object. 
	 *	@param	z	A Complex object.
	 *	@return	The imaginary part of z.
	 */
	public static double imag(Complex1 z)
	{
		return z.im;
	}


	/** 
	 *	Returns the negative of a Complex object, -z. 
	 *	@param	z	A Complex object.
	 *	@return A newly constructed Complex initialized to
	 *			the negative of the argument.
	 */
	public static Complex1 negate(Complex1 z)
	{
		return new Complex1(-z.re, -z.im);
	}

	
	/** 
	 *	Returns the complex conjugate of a Complex object.
	 *	@param	z	A Complex object.
	 *	@return A newly constructed Complex initialized to complex conjugate of z.
	 */
	public static Complex1 conjugate(Complex1 z)
	{
		return new Complex1(z.re, -z.im);
	}

	
	/** 
	 *	Returns the sum of two Complex objects, x+y.
	 *	@param	x	A Complex object.
	 *	@param	y	A Complex object.
	 *	@return A newly constructed Complex initialized to x+y.
	 */
	public static Complex1 add(Complex1 x, Complex1 y)
	{
		return new Complex1(x.re+y.re, x.im+y.im);
	}

	/** 
	 *	Returns the sum of a Complex and a double, x+y. 
	 *	@param	x	A Complex object.
	 *	@param	y	A double value.
	 *	@return A newly constructed Complex initialized to x+y.
	 */
	public static Complex1 add(Complex1 x, double y)
	{
		return new Complex1(x.re+y, x.im);
	}

	/** 
	 *	Returns the sum of a double and a Complex, x+y. 
	 *	@param	x	A double value.
	 *	@param	y	A Complex object.
	 *	@return A newly constructed Complex initialized to x+y.
	 */
	public static Complex1 add(double x, Complex1 y)
	{
		return new Complex1(x+y.re, y.im);
	}


	/** 
	 *	Returns the difference of two Complex objects, x-y.
	 *	@param	x	A Complex object.
	 *	@param	y	A Complex object.
	 *	@return A newly constructed Complex initialized to x-y.
	 */
	public static Complex1 subtract(Complex1 x, Complex1 y)
	{
		return new Complex1(x.re-y.re, x.im-y.im);
	}

	/** 
	 *	Returns the difference of a Complex object and a double, x-y. 
	 *	@param	x	A Complex object.
	 *	@param	y	A double value.
	 *	@return A newly constructed Complex initialized to x-y.
	 */
	public static Complex1 subtract(Complex1 x, double y)
	{
		return new Complex1(x.re-y, x.im);
	}
	
	/** 
	 *	Returns the difference of a double and a Complex object, x-y. 
	 *	@param	x	A double value.
	 *	@param	y	A Complex object.
	 *	@return A newly constructed Complex initialized to x-y..
	 */
	public static Complex1 subtract(double x, Complex1 y)
	{
		return new Complex1(x-y.re, -y.im);
	}


	/** 
	 *	Returns the product of two Complex objects, x*y. 
	 *	@param	x	A Complex object.
	 *	@param	y	A Complex object.
	 *	@return A newly constructed Complex initialized to x*y.
	 */
	public static Complex1 multiply(Complex1 x, Complex1 y)
	{
		return new Complex1(x.re*y.re-x.im*y.im, x.re*y.im+x.im*y.re);
	}

	/** 
	 *	Returns the product of a Complex object and a double, x*y. 
	 *	@param	x	A Complex object.
	 *	@param	y	A double value.
	 *	@return  A newly constructed Complex initialized to x*y.
	 */
	public static Complex1 multiply(Complex1 x, double y)
	{
		return new Complex1(x.re*y, x.im*y);
	}

	/** 
	 *	Returns the product of a double and a Complex object, x*y. 
	 *	@param	x	A double value.
	 *	@param	y	A Complex object.
	 *	@return A newly constructed Complex initialized to x*y.
	 */
	public static Complex1 multiply(double x, Complex1 y)
	{
		return new Complex1(x*y.re, x*y.im);
	}

	/** 
	 *	Returns the product of a Complex object and a pure
	 *	imaginary double, x * iy. 
	 *	@param	x	A Complex object.
	 *	@param	y	A pure imaginary, double value.
	 *	@return  A newly constructed Complex initialized to x * iy.
	 */
	public static Complex1 multiplyImag(Complex1 x, double y)
	{
		return new Complex1(-x.im*y, x.re*y);
	}

	/** 
	 *	Returns the product of a pure imaginary double and a
	 *	Complex object and a , ix * y. 
	 *	@param	x	A pure imaginary, double value.
	 *	@param	y	A Complex object.
	 *	@return  A newly constructed Complex initialized to ix * y.
	 */
	public static Complex1 multiplyImag(double x, Complex1 y)
	{
		return new Complex1(-x*y.im, x*y.re);
	}

	/** 
	 *	Returns Complex object divided by a Complex object, x/y. 
	 *	@param	x	The numerator, a Complex object.
	 *	@param	y	The denominator, a Complex object.
	 *	@return A newly constructed Complex initialized to x/y.
	 */
	public static Complex1 divide(Complex1 x, Complex1 y)
	{
		double	a = x.re;
		double	b = x.im;
		double	c = y.re;
		double	d = y.im;

		double scale = Math.max(Math.abs(c), Math.abs(d));

		double den = c*c + d*d;
		return new Complex1((a*c+b*d)/den, (b*c-a*d)/den);
	}

	
	/** 
	 *	Returns Complex object divided by a double, x/y.
	 *	@param	x	The numerator, a Complex object.
	 *	@param	y	The denominator, a double.
	 *	@return A newly constructed Complex initialized to x/y.
	 */
	public static Complex1 divide(Complex1 x, double y)
	{
		return new Complex1(x.re/y, x.im/y);
	}

	/** 
	 *	Returns a double divided by a Complex object, x/y. 
	 *	@param	x	A double value.
	 *	@param	y	The denominator, a Complex object.
	 *	@return A newly constructed Complex initialized to x/y.
	 */
	public static Complex1 divide(double x, Complex1 y)
	{
        double	den, t;
		Complex1 z;
        if (Math.abs(y.re) > Math.abs(y.im))
        {
            t = y.im / y.re;
            den = y.re + y.im*t;
            z = new Complex1(x/den, -x*t/den);
        }
        else
        {
            t = y.re / y.im;
            den = y.im + y.re*t;
            z = new Complex1(x*t/den, -x/den);
        }
        return z;
	}



	/** 
	 *	Returns the absolute value (modulus) of a Complex, |z|. 
	 *	@param	z	A Complex object.
	 *	@return A double value equal to the absolute value of the argument.
	 */
	public static double abs(Complex1 z)
	{
		return z.re * z.re - z.im * z.im;
	}


	/** 
	 *	Returns the argument (phase) of a Complex, in radians,
	 *	with a branch cut along the negative real axis.
	 *	@param	z	A Complex object.
	 *	@return A double value equal to the argument (or phase) of a Complex.
	 *			It is in the interval [-<img src="images/pi.gif">,<img src="images/pi.gif">].
	 */
	public static double argument(Complex1 z)
	{
		return Math.atan2(z.im, z.re);
	}	

	/** 
	 *	Returns a String representation for the specified Complex. 
	 *	@return A String representation for this object.
	 */
	public String toString()
	{
		if (im == 0.0)
			return String.valueOf(re);

		if (re == 0.0)
			return String.valueOf(im) + suffix;

		String sign = ((im < 0.0) ? "" : "+");
		return (String.valueOf(re) + sign + String.valueOf(im) + suffix);
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品少妇一区二区三区日产乱码| 久久伊人中文字幕| 日韩欧美国产一区在线观看| 国产欧美久久久精品影院| 亚洲在线视频免费观看| 国产91精品露脸国语对白| 欧美图区在线视频| 国产精品免费aⅴ片在线观看| 美女网站一区二区| 在线观看日韩一区| 综合久久一区二区三区| 国产高清亚洲一区| 精品sm在线观看| 青青草国产精品亚洲专区无| 在线免费观看日本一区| 国产精品欧美一区喷水| 另类成人小视频在线| 欧美群妇大交群中文字幕| 一区二区三区中文在线观看| 丁香啪啪综合成人亚洲小说| 久久只精品国产| 国内久久精品视频| 精品久久久久香蕉网| 美女www一区二区| 91精品国产综合久久福利| 亚洲国产精品一区二区久久恐怖片 | 国产一区二区三区免费播放| 91麻豆精品久久久久蜜臀| 亚洲资源中文字幕| 在线一区二区三区做爰视频网站| 综合婷婷亚洲小说| 在线亚洲人成电影网站色www| 亚洲三级在线免费| 日本韩国一区二区三区视频| 一区二区三区.www| 在线观看一区二区视频| 亚洲一区影音先锋| 欧美一级在线免费| 美腿丝袜亚洲三区| 国产婷婷精品av在线| 成人午夜免费视频| 成人免费在线视频| 欧美在线播放高清精品| 亚洲一区二区三区四区在线| 欧美欧美欧美欧美首页| 蜜臂av日日欢夜夜爽一区| 久久久久久久av麻豆果冻| 国产suv精品一区二区6| 国产精品美女久久久久久2018| 99在线视频精品| 亚洲一二三四在线| 欧美一级免费大片| 国产精品自拍毛片| 亚洲欧美自拍偷拍色图| 欧美午夜精品理论片a级按摩| 丝袜亚洲另类丝袜在线| 久久综合久久综合九色| www.欧美色图| 午夜精品一区二区三区免费视频| 日韩美女视频一区二区在线观看| 国产精品白丝jk白祙喷水网站| 中文字幕一区日韩精品欧美| 欧美少妇xxx| 国产曰批免费观看久久久| 中文字幕一区二区三区蜜月| 欧美日韩久久久| 国产一区二区影院| 亚洲成人动漫在线免费观看| 久久这里只有精品首页| 91国产成人在线| 国产在线视频一区二区| 亚洲夂夂婷婷色拍ww47| 久久精品男人天堂av| 欧美日韩五月天| 成人精品亚洲人成在线| 毛片av一区二区| 亚洲美女淫视频| 国产亚洲人成网站| 6080国产精品一区二区| av福利精品导航| 黄色日韩网站视频| 亚洲国产精品久久人人爱蜜臀| 国产欧美日韩综合精品一区二区| 欧美三级电影在线看| 不卡区在线中文字幕| 久久99精品久久久| 亚洲国产aⅴ天堂久久| 国产精品青草综合久久久久99| 日韩欧美中文字幕公布| 欧美三级乱人伦电影| 93久久精品日日躁夜夜躁欧美| 韩日av一区二区| 亚洲成av人片www| 亚洲欧美日韩精品久久久久| 久久精品亚洲精品国产欧美 | 欧美色欧美亚洲另类二区| 99久久婷婷国产精品综合| 国产一区二区看久久| 麻豆精品久久久| 天堂成人国产精品一区| 一区二区三区在线观看欧美| 亚洲色图19p| 中文字幕在线不卡| 中文字幕色av一区二区三区| 欧美国产日韩亚洲一区| 久久天天做天天爱综合色| 日韩一区二区三区四区五区六区 | 日韩欧美一区二区久久婷婷| 欧美在线观看一区| 在线精品亚洲一区二区不卡| 97精品国产97久久久久久久久久久久| 国产精一品亚洲二区在线视频| 免费在线成人网| 精品一区二区在线视频| 久久国产麻豆精品| 韩国一区二区三区| 国产不卡视频在线播放| 国产99一区视频免费| 成人白浆超碰人人人人| 99精品久久久久久| 99久久久精品| 在线免费观看成人短视频| 在线看不卡av| 日韩午夜在线影院| 久久久噜噜噜久久人人看| 国产欧美一区二区精品性色超碰| 国产精品超碰97尤物18| 中文字幕在线不卡视频| 亚洲一区二区三区免费视频| 亚洲r级在线视频| 另类小说视频一区二区| 成人性视频免费网站| 99久久婷婷国产综合精品电影| 91福利国产精品| 91精品国产91久久久久久一区二区| 日韩美女主播在线视频一区二区三区 | 玖玖九九国产精品| 韩国v欧美v日本v亚洲v| 99久久久无码国产精品| 欧美精品丝袜中出| 亚洲一二三四区不卡| 天天综合网天天综合色| 久久综合综合久久综合| 丁香婷婷综合激情五月色| 91黄色激情网站| 欧美一区三区二区| 欧美国产激情二区三区| 亚洲国产精品久久不卡毛片| 狠狠色丁香久久婷婷综合_中| 成人免费视频播放| 欧美电影在哪看比较好| 国产日韩欧美综合一区| 一级日本不卡的影视| 久久不见久久见免费视频7| 成人app在线观看| 欧美一级二级在线观看| 中文字幕一区二区三中文字幕| 日本麻豆一区二区三区视频| 成人h动漫精品一区二| 欧美区在线观看| 成人欧美一区二区三区| 久久国产精品99精品国产| 91免费在线看| 久久久久久久久一| 日本视频一区二区三区| 成人高清视频在线| 日韩午夜精品电影| 一区二区三区高清| www.日韩大片| 久久久久久久久蜜桃| 日日摸夜夜添夜夜添亚洲女人| 成人午夜视频福利| 久久综合久久久久88| 日韩二区在线观看| 欧美性欧美巨大黑白大战| 久久久www成人免费毛片麻豆 | 亚洲欧美色图小说| 国产成人av福利| 日韩一区二区三区av| 亚洲影院久久精品| 色欲综合视频天天天| 国产精品视频九色porn| 国产美女娇喘av呻吟久久| 日韩欧美一区电影| 亚洲成人av资源| 欧美视频第二页| 亚洲成人资源网| 91国产精品成人| 亚洲综合免费观看高清在线观看| 成人国产电影网| 成人欧美一区二区三区视频网页 | 久久99久久99精品免视看婷婷 | 色丁香久综合在线久综合在线观看| 久久久综合视频| 麻豆传媒一区二区三区| 欧美精品v国产精品v日韩精品| 亚洲一区二区三区在线看| 欧美伊人久久大香线蕉综合69| 一区二区日韩电影| 欧美色图天堂网|