Exemplo n.º 1
0
    function fully_reduce(matrix){
        var echelon_result = row_echelon(matrix)
            , echelon = echelon_result[0]
            , change = echelon_result[1]
            , augmentation = echelon_result[2]
            , height = echelon.length
            , width = echelon[0].length
            , size = width < height ? width : height
            , column_index = size
            , row_index = column_index-1
            , target
            ;

        // make the diagonal 1
        u.times(width < height ? width : height, function(row_index){
            var row = echelon[row_index];
            echelon[row_index] = m.disperse(echelon[row_index], row[row_index])
            augmentation[row_index] = m.disperse(augmentation[row_index], row[row_index])
            change = change.per(row[row_index])
        })

        while ( column_index -- > 0 ) {
            row_index = column_index
            while ( row_index -- > 0 ) {
                target = echelon[row_index][column_index]
                echelon[row_index] = m.sub(echelon[row_index], m.scale(echelon[column_index], target))
                augmentation[row_index] = m.sub(augmentation[row_index], m.scale(augmentation[column_index], target))
            }
        }

        return [echelon, augmentation]

    }
Exemplo n.º 2
0
 matrix.forEach(function(row, row_index){
     if ( row_index < row.length ) {
         u.times(row_index, function(column_index){
             if ( row[column_index] !== zero ) {
                 result = false
             }
         })
     }
 })
Exemplo n.º 3
0
    function determinant(matrix){

        if ( matrix.length != matrix[0].length) return undefined

        var echelon = row_echelon(matrix);

        return u.times(echelon[0].length, function(row_index){
            return echelon[0][row_index][row_index]
        }).reduce(r.mul).per(echelon[1])

    }
Exemplo n.º 4
0
        echelon.forEach(function(row, row_index){
            u.times(row_index, function(column_index){
                var pivot, pivot_row, lead, multiple;

                pivot = echelon[column_index][column_index]
                lead = echelon[row_index][column_index]
                scalar = lead.per(pivot)

                echelon[row_index] = m.sub(echelon[row_index]
                    , m.scale(echelon[column_index],  scalar))

                augmentation[row_index] = m.sub(augmentation[row_index]
                    , m.scale(augmentation[column_index],  scalar))

            })
        })