Support array types in arithmetic for ComplexMatrix2D
completed by: Kristaba
Task Description: Parrot-Linear-Algebra (PLA) is a plugin library that adds linear algebra (matrix and vector) support for the Parrot virtual machine. ComplexMatrix2D is a Parrot data type that acts as a 2D matrix of complex values. ComplexMatrix2D can perform arithmetic operations with scalars, such as adding a single value to every element in the matrix. However, not all possible input data types are supported.
Inputs which are strings are currently parsed into Complex values in the function get_complex_value_from_pmc() (src/lib/math_common.c). We would like the ability to treat 2-element arrays as complex values too. The first element in the array would be the real part, and the second element would be the imaginary part.
The student should:
- Create a fork of PLA on github
- Modify the function src/lib/math_common.c:get_complex_value_from_pmc() to pull a complex value out of a 2-element array (longer arrays should not be handled. 1-element or 0-element array behavior is up to the discretion of the student)
- Add tests to t/methods/complexmatrix2d/gemm.t to show that the parameters Alpha and Beta can both be passed as arrays without triggering errors
- Add at least 10 tests for the new behavior, spread out among any of the following files:
- t/pmc/complexmatrix2d.t (set_pmc_keyed and set_pmc_keyed_int VTABLEs)
- Open a pull request at github to merge in the new features.
Benefits: Right now complex values can only be specified using either a String or a Complex PMC (usually initialized from a string). Adding in the ability to specify Complex values using array types adds much flexibility to the interface and allows the ComplexMatrix2D PMC type to be more useful to it's users.
Links: https://github.com/Whiteknight/parrot-linear-algebra, https://github.com/Whiteknight/parrot-linear-algebra/issues#issue/17