⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 point.cs

📁 Cluster validation program
💻 CS
字号:
using System;

namespace ClusterLibrary
{
	/// <summary>
	/// Summary description for Point.
	/// </summary>
	public class Point : System.Collections.ArrayList 
	{

		// 捞 Point啊 加秦 乐绰 Cluster甸狼 府胶飘 函荐捞促.
		private System.Collections.ArrayList cluster_list;

		/// <summary>
		/// Point狼 积己磊 ( ROW 单捞磐甫 历厘窍绰 Point ) 
		/// </summary>
		/// <param name="nClusters"> Point啊 加秦 乐绰 (int) Cluster甸狼 肮荐 </param>
		public Point(int nClusters)
		{
			// 捞 Point啊 加秦 乐绰 Cluster甸狼 府胶飘甫 积己茄促.
			// nClusters绰 捞 Point啊 加秦 乐绰 Cluster甸狼 肮荐捞促.
			this.cluster_list = new System.Collections.ArrayList( nClusters );
		}

		/// <summary>
		/// Point狼 积己磊 ( 单捞磐 拌魂 苞沥 吝埃俊 积扁绰 Point )
		/// </summary>
		public Point()
		{
		}

		/// <summary>
		/// Point啊 加秦 乐绰 Cluster狼 沥焊甫 历厘茄促.
		/// </summary>
		/// <param name="n"></param>
		public void SetClusterInfo( int n )
		{
			this.cluster_list.Add( n );
		}

		/// <summary>
		/// Point啊 n锅掳 Set俊辑 割锅掳 Cluster俊 加窍绰瘤 弊 蔼阑 府畔茄促. 
		/// </summary>
		/// <param name="n"></param>
		/// <returns></returns>
		public int GetClusterInfo( int n )
		{
			return (int) this.cluster_list[n];
		}

		/// <summary>
		/// Point啊 加秦 乐绰 Cluster狼 沥焊甫 历厘茄促.
		/// </summary>
		/// <param name="n"></param>
		public void SetClusterInfo( int[] n )
		{
			this.AddRange( n );
		}



		/// <summary>
		/// Point1苞 Point2甫 歹窍绰 Operator
		/// </summary>
		/// <param name="pt1"></param>
		/// <param name="pt2"></param>
		/// <returns></returns>
		public static Point operator + ( Point pt1, Point pt2 ) {
			Point addResult = new Point();
			if ( pt1.Count > pt2.Count ){
				for ( int i = 0; i < pt1.Count ; i ++ ){
					addResult.Add ( (double) pt1[i] );
				}
				return addResult;
			}else if ( pt1.Count< pt2.Count ){
				for ( int i = 0; i < pt2.Count; i ++ ){
					addResult.Add( (double) pt2[i] );
				}
				return addResult;
			}
			try{
				for ( int i = 0; i < pt1.Count ; i++ ){
					addResult.Add( (double)pt1[i] + (double)pt2[i] );
				}
			}
			catch ( System.Exception e ){
				System.Console.WriteLine( (e.StackTrace) ); 
				System.Console.WriteLine( e.ToString() );
			}
			return addResult;
		}

		/// <summary>
		/// Point1苞 Point2甫 哗绰 Operator
		/// </summary>
		/// <param name="pt1"></param>
		/// <param name="pt2"></param>
		/// <returns></returns>
		public static Point operator - ( Point pt1, Point pt2 ) {
			Point minusResult = new Point();
			
			if ( pt1.Count > pt2.Count ){
				for ( int i = 0; i < pt1.Count ; i++){
					minusResult.Add( (double)pt1[i] );
				}
				return minusResult;
			}else if ( pt1.Count < pt2.Count ){
				for ( int i = 0; i < pt2.Count ; i++){
					minusResult.Add( (double)pt1[i] );
				}			
			}
			try{
				for ( int i = 0; i < pt1.Count ; i++ ){
					minusResult.Add( (double)pt1[i] - (double)pt2[i] );
				}
			}
			catch ( System.Exception e ){
				System.Console.WriteLine( (e.StackTrace) ); 
				System.Console.WriteLine( e.ToString() );
			}
			return minusResult;
		}

		/// <summary>
		/// Point狼 阿 谅钎蔼阑 (double)n栏肺 唱穿绰 窃荐
		/// </summary>
		/// <param name="pt"></param>
		/// <param name="n"></param>
		/// <returns> 唱床柳 Point狼 蔼 </returns>
		public static Point operator / (Point pt, double n ){
			Point divideResult = new Point();
			for ( int i = 0; i < pt.Count ; i ++ ){
				divideResult.Add( (double) pt[i] / n );
			}
			return divideResult;
		}

		/// <summary>
		/// Point狼 阿 谅钎蔼阑 (double) n铰 窍绰 窃荐
		/// </summary>
		/// <param name="pt"></param>
		/// <param name="n"></param>
		/// <returns> (double) n铰茄 Point狼 蔼 </returns>
		public static Point operator ^ (Point pt, double n ){
			Point powResult = new Point();
			for ( int i = 0; i < pt.Count; i++ ){
				powResult.Add( System.Math.Pow((double) pt[i], n ));
			}
			return powResult;
		}

		/// <summary>
		/// Point狼 农扁甫 Return 窍绰 窃荐 for J#
		/// </summary>
		/// <returns></returns>
		public int size(){
			return this.Count;
		}


		/// <summary>
		/// Point狼 Indexer for J#
		/// </summary>
		new public double this[int index]{
			set {
				if ( index > this.Count )
					throw new Exception ( "Index out of range." );
				else 
					base[index] = value;
			}
			get {
				if ( index > this.Count )
					throw new Exception ( "Index out of range." );
				else
					return (double)base[index];
			}
		}

		/// <summary>
		/// Point俊 甸绢乐绰 谅钎甫 波晨
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public double GetPoint( int index ){
			if ( index >= this.Count )
				throw new Exception ( "Index out of range." );
			return (double)this[index];
		}

		/// <summary>
		/// Point俊 甸绢乐绰 谅钎甫 波晨 for J#
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public double getValueAt( int index ){
			return this.GetPoint( index );
		}

		public bool IsEmpty(){
			return ( this.size() == 0 );
		}

		public void addValue( double number ){
			this.Add( number );
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -