#!/usr/bin/perl -w

# ----------------------------------------------------------------
# John Kerl
# kerl.john.r@gmail.com
# 2005-06-28
# ----------------------------------------------------------------

# Setup information:
# (1) Obtain my PMATLIB.pm;
# (2) Put PMATLIB.pm somewhere, e.g. the $HOME/bin directory;
# (3) Include that directory in the PERLLIB environment variable.
#     For bash, if PERLLIB exists:         export PERLLIB=$HOME/bin
#     For bash, if PERLLIB does not exist: export PERLLIB=$PERLLIB:$HOME/bin
#     For csh, if PERLLIB exists:          setenv PERLLIB $HOME/bin
#     For csh, if PERLLIB does not exist:  setenv PERLLIB ${PERLLIB}:$HOME/bin
use PMATLIB;

while (@ARGV) {
	last unless $ARGV[0] =~ m/^-/;

	if (pmatlib_opt(\@ARGV)) {
		;
	}
	else {
		usage();
	}
}

@A = (); $nr = 0; $nc = 0; 
@kerbas = ();
$dimker = 0;

read_matrix(\@A, \$nr, \$nc, $ARGV[0]);
if (get_kernel_basis(\@A, $nr, $nc, \@kerbas, \$dimker)) {
	print_matrix(\@kerbas, $dimker, $nc);
}
else {
	print "Kernel is trivial.\n";
}

# ----------------------------------------------------------------
sub usage
{
	die
		"Usage: $0 [options] [input file name]\n" .
		"Options:\n" .
		"  -w:  specify field width\n" .
		"  -p:  specify number of decimal places\n" .
		"  -f:  use %f format\n" .
		"  -d:  use %d format\n";
}
