Skip to content

matrix-cos-angle divides by zero on zero matrices #117

@samth

Description

@samth

matrix-cos-angle raises a /: division by zero error when either argument is a zero matrix:

> (matrix-cos-angle (matrix [[0]]) (matrix [[1]]))
/: division by zero

Found by DrDr here: https://drdr.racket-lang.org/72356/racket/share/pkgs/math-test/math/tests/matrix-tests.rkt

This code in matrix-basic.rkt looks suspicious:

[(or (nan? mxA) (nan? mxB) (= 0 mxA) (= 0 mxB))
 (/ (matrix-dot A B) (* mxA mxB))]

When mxA or mxB is 0, (* mxA mxB) is 0, causing division by zero.

I don't know what it should return, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions