C Sharp中的C均值算法

C Sharp中的C均值算法

问题描述:

如何将此Java代码转换为.net代码,请帮助它对我来说很重要

how to convert this java code to .net code please help it is very important for me

Centroid.java
class Centroid {
    private double mCx, mCy;
    private Cluster mCluster;

    public Centroid(double cx, double cy) {
        this.mCx = cx;
        this.mCy = cy;
    }

    public void calcCentroid() { //only called by CAInstance
        int numDP = mCluster.getNumDataPoints();
        double tempX = 0, tempY = 0;
        int i;
        //caluclating the new Centroid
        for (i = 0; i < numDP; i++) {
            tempX = tempX + mCluster.getDataPoint(i).getX(); 
            //total for x
            tempY = tempY + mCluster.getDataPoint(i).getY(); 
            //total for y
        }
        this.mCx = tempX / numDP;
        this.mCy = tempY / numDP;
        //calculating the new Euclidean Distance for each Data Point
        tempX = 0;
        tempY = 0;
        for (i = 0; i < numDP; i++) {
            mCluster.getDataPoint(i).calcEuclideanDistance();
        }
        //calculate the new Sum of Squares for the Cluster
        mCluster.calcSumOfSquares();
    }

    public void setCluster(Cluster c) {
        this.mCluster = c;
    }

    public double getCx() {
        return mCx;
    }

    public double getCy() {
        return mCy;
    }

    public Cluster getCluster() {
        return mCluster;
    }

}

请检查链接,您将获得有关如何将Java应用程序直接转换为C#的信息 [ ^ ]
Please check the link you will get information how to convert java applications to C# directly http://msdn.microsoft.com/en-us/library/ms973842.aspx[^]