public void MergeWith(SpeakerCluster target) { if (target == null) { throw new NullReferenceException(); } var it = target._segmentSet.GetEnumerator(); while (it.MoveNext()) { if (!AddSegment(it.Current)) { Console.WriteLine("Something doesn't work in mergeWith method, Cluster class"); } } int rowDim = FeatureMatrix.getRowDimension() + target.FeatureMatrix.getRowDimension(); int colDim = FeatureMatrix.getColumnDimension(); var combinedFeatures = new Array2DRowRealMatrix(rowDim, colDim); combinedFeatures.setSubMatrix(FeatureMatrix.getData(), 0, 0); combinedFeatures .setSubMatrix(target.FeatureMatrix.getData(), FeatureMatrix.getRowDimension(), 0); _bicValue = SpeakerIdentification.GetBICValue(combinedFeatures); FeatureMatrix = new Array2DRowRealMatrix(combinedFeatures.getData()); }
public SpeakerCluster(SpeakerCluster c) { _segmentSet = new SortedSet <Segment>(); FeatureMatrix = new Array2DRowRealMatrix(c.FeatureMatrix.getData()); var it = c._segmentSet.GetEnumerator(); while (it.MoveNext()) { AddSegment(it.Current); } }
static double ComputeDistance(SpeakerCluster c1, SpeakerCluster c2) { int rowDim = c1.FeatureMatrix.getRowDimension() + c2.FeatureMatrix.getRowDimension(); int colDim = c1.FeatureMatrix.getColumnDimension(); Array2DRowRealMatrix combinedFeatures = new Array2DRowRealMatrix(rowDim, colDim); combinedFeatures.setSubMatrix(c1.FeatureMatrix.getData(), 0, 0); combinedFeatures.setSubMatrix(c2.FeatureMatrix.getData(), c1.FeatureMatrix.getRowDimension(), 0); double bicValue = GetBICValue(combinedFeatures); double d = Segment.FeaturesSize; double penalty = 0.5 * (d + 0.5 * d * (d + 1)) * Math.Log(combinedFeatures.getRowDimension()) * 2; return(bicValue - c1.GetBicValue() - c2.GetBicValue() - penalty); }