Skip to content

Commit c37592e

Browse files
authored
Merge pull request #1268 from Alex-Jordan/restructure-pod-macros-math
Restructire the POD of macros (math)
2 parents 90fd2cc + 39cc81b commit c37592e

22 files changed

+680
-656
lines changed

macros/math/LinearProgramming.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ =head1 NAME
44
LinearProgramming.pl - Macros for the simplex tableau for linear programming
55
problems.
66
7-
=head1 SYNPOSIS
7+
=head1 SYNOPSIS
88
99
Macros related to the simplex method for Linear Programming.
1010
@@ -33,7 +33,7 @@ =head1 DESCRIPTION
3333
3434
or something similar which arises after pivoting.
3535
36-
=head1 MACROS
36+
=head1 FUNCTIONS
3737
3838
=head2 lp_pivot
3939

macros/math/MatrixCheckers.pl

Lines changed: 16 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
sub _MatrixCheckers_init { }; # don't reload this file
2-
3-
=pod
41

52
=head1 NAME
63
7-
MatrixCheckers.pl
4+
MatrixCheckers.pl - Provides subroutines for answer checking using MathObjects
5+
matrices with real entries.
86
97
=head1 SYNOPSIS
108
@@ -17,57 +15,47 @@ =head1 DESCRIPTION
1715
First, load the C<MatrixCheckers.pl> macro file. If the basis has
1816
more than one vector, also load C<parserMultiAnswer.pl>.
1917
20-
=over 12
21-
22-
=item loadMacros("PGstandard.pl","MathObjects.pl","parserMultiAnswer.pl","MatrixCheckers.pl");
23-
24-
=back
18+
loadMacros("PGstandard.pl","MathObjects.pl","parserMultiAnswer.pl","MatrixCheckers.pl");
2519
2620
For a matrix that has a single column or row, the way to use the
2721
answer checkers is the same as using a custom answer checker
28-
inside of C<cmp(checker=>~~&name_of_answer_checker_subroutine)>
22+
inside of C<< cmp(checker=>~~&name_of_answer_checker_subroutine) >>
2923
such as
3024
31-
=over 12
25+
ANS( Matrix([[1],[2],[3]])->cmp( checker=>~~&basis_checker_one_column ) );
26+
ANS( Matrix([[1],[2],[3]])->cmp( checker=>~~&unit_basis_checker_one_column ) );
3227
33-
=item C<ANS( Matrix([[1],[2],[3]])->cmp( checker=>~~&basis_checker_one_column ) );>
34-
35-
=item C<ANS( Matrix([[1],[2],[3]])->cmp( checker=>~~&unit_basis_checker_one_column ) );>
36-
37-
=back
3828
3929
The "one column" at the end of the checker name refers to the
4030
fact that the student answer is a one-column matrix. The "unit
4131
basis checker" ensures that the student answer has unit length.
4232
33+
=head2 Checkers
34+
4335
For answers that are a collection of column or row vectors, the
4436
way to use the answer checkers is inside of a MultiAnswer object.
4537
The macro C<parserMultiAnswer.pl> should also be loaded.
4638
The answer checkers that should be used inside a MultiAnswer
4739
object are:
4840
49-
=over 12
41+
=head3 basis_checker_columns
5042
51-
=item C<basis_checker_columns>
43+
=head3 orthonormal_basis_checker_columns
5244
53-
=item C<orthonormal_basis_checker_columns>
45+
=head3 basis_checker_rows
5446
55-
=item C<basis_checker_rows>
47+
=head3 orthonormal_basis_checker_rows
5648
57-
=item C<orthonormal_basis_checker_rows>
49+
=head3 parametric_plane_checker_columns
5850
59-
=item C<parametric_plane_checker_columns>
60-
61-
=back
51+
=head2 Examples
6252
6353
Here is an example of how to use these answer checkers.
6454
In the setup section of the PG file we create two 3 x 1 MathObject
6555
matrices with real-entries that serve as basis vectors. The object
6656
C<$multians> takes the basis vectors as input and passes them
6757
to the custom answer checker called by C<checker =<gt>...>.
6858
69-
=over 12
70-
7159
$basis1 = Matrix([1/sqrt(2), 0, 1/sqrt(2)])->transpose;
7260
$basis2 = Matrix([0,1,0])->transpose;
7361
@@ -79,17 +67,12 @@ =head1 DESCRIPTION
7967
checker => ~~&orthonormal_basis_checker_columns,
8068
);
8169
82-
=back
83-
8470
In the main text portion of the PG file, we use C<\{ $multians-<gt>ans_array(15) \}>
8571
to create an array of text boxes that are 15 characters wide and have square
8672
brackets around them to look like a matrix. The braces around the vectors, which
8773
are produced by C<\(\Bigg\lbrace\)> and C<\(\Bigg\rbrace\)>, are a matter of personal
8874
preference (since a basis is an ordered set, I like to include braces).
8975
90-
91-
92-
Context()->texStrings;
9376
BEGIN_TEXT
9477
Find an orthonormal basis for...
9578
$BR
@@ -101,18 +84,11 @@ =head1 DESCRIPTION
10184
\(\Bigg\rbrace.\)
10285
$ECENTER
10386
END_TEXT
104-
Context()->normalStrings;
105-
106-
10787
10888
The answer evaluation section of the PG file is totally standard.
10989
110-
=over 12
111-
11290
ANS( $multians->cmp );
11391
114-
=back
115-
11692
The C<parametric_plane_checker_columns> should be used for
11793
solutions to non-homogeneous systems of linear equations for
11894
which the solution is essentially a point plus the span of
@@ -122,17 +98,11 @@ =head1 DESCRIPTION
12298
particular solution), while the remaining vectors are a basis for
12399
the hyperplane (i.e., they span the homogeneous solution set).
124100
125-
=head1 AUTHORS
126-
127-
Paul Pearson, Hope College, Department of Mathematics
128-
129101
=cut
130102

131-
################################################
132-
133-
loadMacros("MathObjects.pl",); # , will "parserMultiAnswer.pl" create an infinite loop?
103+
sub _MatrixCheckers_init { }; # don't reload this file
134104

135-
################################################
105+
loadMacros("MathObjects.pl",); # , will "parserMultiAnswer.pl" create an infinite loop?
136106

137107
sub concatenate_columns_into_matrix {
138108

@@ -145,8 +115,6 @@ sub concatenate_columns_into_matrix {
145115

146116
}
147117

148-
##########################################
149-
150118
sub basis_checker_one_column {
151119

152120
my ($correct, $student, $answerHash) = @_;
@@ -168,8 +136,6 @@ sub basis_checker_one_column {
168136

169137
}
170138

171-
##########################################
172-
173139
sub basis_checker_columns {
174140

175141
my ($correct, $student, $answerHash) = @_;
@@ -215,8 +181,6 @@ sub basis_checker_columns {
215181

216182
}
217183

218-
#############################################
219-
220184
sub unit_basis_checker_one_column {
221185

222186
my ($correct, $student, $answerHash) = @_;
@@ -236,8 +200,6 @@ sub unit_basis_checker_one_column {
236200

237201
}
238202

239-
###############################################
240-
241203
sub orthonormal_basis_checker_columns {
242204

243205
my ($correct, $student, $answerHash) = @_;
@@ -290,8 +252,6 @@ sub orthonormal_basis_checker_columns {
290252

291253
}
292254

293-
##############################################
294-
295255
sub basis_checker_rows {
296256

297257
my ($correct, $student, $answerHash) = @_;
@@ -338,8 +298,6 @@ sub basis_checker_rows {
338298

339299
}
340300

341-
#############################################
342-
343301
sub orthonormal_basis_checker_rows {
344302

345303
my ($correct, $student, $answerHash) = @_;
@@ -393,8 +351,6 @@ sub orthonormal_basis_checker_rows {
393351

394352
}
395353

396-
##############################################
397-
398354
sub parametric_plane_checker_columns {
399355

400356
my ($correct, $student, $answerHash) = @_;
@@ -457,6 +413,4 @@ sub parametric_plane_checker_columns {
457413

458414
}
459415

460-
########################################################
461-
462416
1;

macros/math/MatrixReduce.pl

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
sub _MatrixReduce_init { }; # don't reload this file
2-
3-
=pod
41

52
=head1 NAME
63
7-
MatrixReduce.pl - reduced row echelon form, row
8-
operations, and elementary matrices.
4+
MatrixReduce.pl - Provides subroutines for elementary matrix computations using
5+
MathObjects matrices.
96
10-
=head1 SYNOPSIS
7+
=head1 DESCRIPTION
118
12-
Provides subroutines for elementary matrix
13-
computations using MathObjects matrices.
9+
Provides subroutines for elementary matrix computations using MathObjects
10+
matrices, such as finding the reduced row echelon form, performing row
11+
operations, and constructing elementary matrices.
1412
1513
=over 12
1614
@@ -68,7 +66,7 @@ =head1 SYNOPSIS
6866
6967
=back
7068
71-
=head1 DESCRIPTION
69+
=head1 SYNOPSIS
7270
7371
Usage:
7472
@@ -147,9 +145,10 @@ =head1 AUTHORS
147145
# a consistent system. Also, with randomly chosen matrices, it is
148146
# possible to get rows or columns of zeros, so watch out!
149147

148+
sub _MatrixReduce_init { }; # don't reload this file
149+
150150
loadMacros("MathObjects.pl", "contextFraction.pl",);
151151

152-
################################################
153152
# rref: input and output are MathObject matrices.
154153
# Should be run in Fraction context for best results.
155154

@@ -201,7 +200,6 @@ sub rref_perl_array {
201200
return @A;
202201
}
203202

204-
################################################
205203
# This was written by Davide Cervone.
206204
# http://webwork.maa.org/moodle/mod/forum/discuss.php?d=2970
207205

@@ -216,15 +214,11 @@ sub change_matrix_entry {
216214
}
217215
}
218216

219-
################################################
220-
221217
sub identity_matrix {
222218
my $n = shift;
223219
return Value::Matrix->I($n);
224220
}
225221

226-
################################################
227-
228222
sub elem_matrix_row_switch {
229223

230224
# $n = number of rows (and columns) in matrix
@@ -241,8 +235,6 @@ sub elem_matrix_row_switch {
241235

242236
}
243237

244-
#########################################
245-
246238
sub elem_matrix_row_mult {
247239

248240
# $n = number of rows (and columns) in matrix
@@ -263,8 +255,6 @@ sub elem_matrix_row_mult {
263255

264256
}
265257

266-
######################################
267-
268258
sub elem_matrix_row_add {
269259

270260
# $n = number of rows (and columns) in matrix
@@ -285,16 +275,14 @@ sub elem_matrix_row_add {
285275

286276
}
287277

288-
##############################################
289-
290278
sub row_add {
291279

292280
# put (row i) + s * (row j) into (row i)
293281

294-
my $M = shift; # MathObject matrix
295-
my $i = shift; # row index
296-
my $j = shift; # row index
297-
my $s = shift; # scaling factor
282+
my $M = shift; # MathObject matrix
283+
my $i = shift; # row index
284+
my $j = shift; # row index
285+
my $s = shift; # scaling factor
298286

299287
my ($r, $c) = $M->dimensions;
300288
if (($i < 1) or ($j < 1) or ($i > $r) or ($j > $r)) {
@@ -318,8 +306,6 @@ sub row_add {
318306

319307
}
320308

321-
####################################
322-
323309
sub row_switch {
324310

325311
my $M = shift; # MathObject matrix
@@ -336,8 +322,6 @@ sub row_switch {
336322

337323
}
338324

339-
#########################################
340-
341325
sub row_mult {
342326

343327
my $M = shift; # MathObject matrix
@@ -357,8 +341,6 @@ sub row_mult {
357341

358342
}
359343

360-
####################################
361-
362344
sub apply_fraction_to_matrix_entries {
363345

364346
my $M = shift;

0 commit comments

Comments
 (0)