Esempio n. 1
0
autoConfiguration Configuration_create (long numberOfPoints, long numberOfDimensions) {
	try {
		autoConfiguration me = Thing_new (Configuration);
		TableOfReal_init (me.peek(), numberOfPoints, numberOfDimensions);
		my w = NUMvector<double> (1, numberOfDimensions);
		TableOfReal_setSequentialRowLabels (me.peek(), 0, 0, nullptr, 1, 1);
		TableOfReal_setSequentialColumnLabels (me.peek(), 0, 0, U"dimension ", 1, 1);

		my metric = 2;
		Configuration_setDefaultWeights (me.peek());
		Configuration_randomize (me.peek());
		return me;
	} catch (MelderError) {
		Melder_throw (U"Configuration not created.");
	}
}
Esempio n. 2
0
EditDistanceTable EditDistanceTable_create (Strings target, Strings source) {
    try {
        autoEditDistanceTable me = Thing_new (EditDistanceTable);
        long numberOfSourceSymbols = source -> numberOfStrings, numberOfTargetSymbols = target -> numberOfStrings;
        TableOfReal_init (me.peek(), numberOfTargetSymbols + 1, numberOfSourceSymbols + 1);
        TableOfReal_setColumnLabel (me.peek(), 1, U"");
        for (long j = 1; j <= numberOfSourceSymbols; j++) {
            my columnLabels[j + 1] = Melder_dup (source -> strings[j]);
        }
        TableOfReal_setRowLabel (me.peek(), 1, U"");
        for (long i = 1; i <= numberOfTargetSymbols; i++) {
            my rowLabels[i + 1] = Melder_dup (target -> strings[i]);
        }
        my warpingPath = WarpingPath_create (numberOfTargetSymbols + numberOfSourceSymbols + 1);
        my editCostsTable = EditCostsTable_createDefault ();
        EditDistanceTable_findPath (me.peek(), 0);
        return me.transfer();
    } catch (MelderError) {
        Melder_throw (U"EditDistanceTable not created.");
    }
}