DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');

Context('Matrix');

my $rows    = random(3, 4);
my $columns = random(4, 5);
my $rank    = random(2, 3);

$sageReply = AskSage(<<"END_CODE", { seed => $problemSeed });
WEBWORK['M'] = random_matrix(
    QQ, $rows, $columns, algorithm = 'echelonizable', rank = $rank
).rows()
WEBWORK['RREF'] = matrix(QQ, WEBWORK['M']).rref().rows()
END_CODE

if (sageReturnedFail($sageReply)) {
    # Fallback values for $M and $RREF in case the AskSage call fails.
    $M = Matrix([ [ -4, 8, -12, 15 ], [ 5, -10, 15, -19 ], [ 2, -4, 6, -5 ] ]);
    $RREF = Matrix([ [ 1, -2, 3, 0 ], [ 0, 0, 0, 1 ], [ 0, 0, 0, 0 ] ]);
} else {
    $M    = Matrix($sageReply->{webwork}{M});
    $RREF = Matrix($sageReply->{webwork}{RREF});
}

BEGIN_PGML
Give the reduced row echelon form of the following matrix.

[```[$M]```]

The reduced row echelon form is

[_]*{$RREF}
END_PGML

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();