import { Matrix } from 'ml-matrix';
const absDiff = (a, b) => Math.abs(a - b);
/**
 * Generate a cost matrix from two set of values using the function passed. by default it
 * generate the cost matrix of absolute value of differences.
 * @param rowsArray - array of values that will represent the rows of the cost matrix.
 * @param columnsArray - array of values that will represent the columns of the cost matrix.
 * @param options - options.
 * @returns a matrix instance with dimensions rowsArray.length x columnsArray.length.
 */
export function xCostMatrix(rowsArray, columnsArray, options = {}) {
    const { fct = absDiff } = options;
    const nbRows = rowsArray.length;
    const nbColumns = columnsArray.length;
    const result = new Matrix(nbRows, nbColumns);
    for (let r = 0; r < nbRows; r++) {
        for (let c = 0; c < nbColumns; c++) {
            result.set(r, c, fct(rowsArray[r], columnsArray[c]));
        }
    }
    return result;
}
//# sourceMappingURL=xCostMatrix.js.map