{"action":"opened","issue":{"url":"https://api.github.com/repos/josdejong/mathjs/issues/708","repository_url":"https://api.github.com/repos/josdejong/mathjs","labels_url":"https://api.github.com/repos/josdejong/mathjs/issues/708/labels{/name}","comments_url":"https://api.github.com/repos/josdejong/mathjs/issues/708/comments","events_url":"https://api.github.com/repos/josdejong/mathjs/issues/708/events","html_url":"https://github.com/josdejong/mathjs/issues/708","id":175818643,"number":708,"title":"Extending multiply matrices behavior","user":{"login":"albertoantunes","id":8058041,"avatar_url":"https://avatars.githubusercontent.com/u/8058041?v=3","gravatar_id":"","url":"https://api.github.com/users/albertoantunes","html_url":"https://github.com/albertoantunes","followers_url":"https://api.github.com/users/albertoantunes/followers","following_url":"https://api.github.com/users/albertoantunes/following{/other_user}","gists_url":"https://api.github.com/users/albertoantunes/gists{/gist_id}","starred_url":"https://api.github.com/users/albertoantunes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertoantunes/subscriptions","organizations_url":"https://api.github.com/users/albertoantunes/orgs","repos_url":"https://api.github.com/users/albertoantunes/repos","events_url":"https://api.github.com/users/albertoantunes/events{/privacy}","received_events_url":"https://api.github.com/users/albertoantunes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-08T17:50:40Z","updated_at":"2016-09-08T17:50:40Z","closed_at":null,"body":"I am using mathjs to do some matrices multiplications, and in some cases am hitting the issue of having zero multiplied by Inifinty or -Infinity. The default javascript behavior is to have these evaluate to NaN (0 * Infinity = NaN), but in my case I need it to be evaluated to zero (0 * Infinity = 0). I've been able to do this by changing the specific function being hit in my case (_multiplyDenseMatrixDenseMatrix) and inside that function algorithm do the checking to see if sum is NaN give it the value of 0:\r\n\r\n```\r\nvar _multiplyDenseMatrixDenseMatrix = function (a, b) {\r\n\t   ...\r\n\t    // loop matrix a rows\r\n\t    for (var i = 0; i < arows; i++) {\r\n\t      // current row\r\n\t      var row = adata[i];\r\n\t      // initialize row array\r\n\t      c[i] = [];\r\n\t      // loop matrix b columns\r\n\t      for (var j = 0; j < bcolumns; j++) {\r\n\t        // sum (avoid initializing sum to zero)\r\n\t        var sum = mf(row[0], bdata[0][j]);\r\n\t        if(isNaN(sum)) { sum = 0; }\r\n\t        // loop matrix a columns\r\n\t        for (var x = 1; x < acolumns; x++) {\r\n\t          // multiply & accumulate\r\n\t            var mtemp = mf(row[x], bdata[x][j]);\r\n\t            if(isNaN(mtemp)) { mtemp = 0; }\r\n\t          sum = af(sum, mtemp);\r\n\t        }\r\n\t        c[i][j] = sum;\r\n\t      }\r\n\t    }\r\n          ...\r\n```\r\n\r\nThis feels very hackish tough, and I was wondering if there is a better way to extend this function without having to modify it directly. I tried using the [math.import](http://mathjs.org/docs/core/extension.html#extension) with the override option but had no luck with it. Is there any better way to handling this situation that I am missing?"}}
{"actor":{"display_login":"albertoantunes"}}