{"action":"created","issue":{"url":"https://api.github.com/repos/accord-net/framework/issues/106","labels_url":"https://api.github.com/repos/accord-net/framework/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/accord-net/framework/issues/106/comments","events_url":"https://api.github.com/repos/accord-net/framework/issues/106/events","html_url":"https://github.com/accord-net/framework/issues/106","id":85367844,"number":106,"title":"Unsafe code is unsafe","user":{"login":"nomnomdom","id":4212248,"avatar_url":"https://avatars.githubusercontent.com/u/4212248?v=3","gravatar_id":"","url":"https://api.github.com/users/nomnomdom","html_url":"https://github.com/nomnomdom","followers_url":"https://api.github.com/users/nomnomdom/followers","following_url":"https://api.github.com/users/nomnomdom/following{/other_user}","gists_url":"https://api.github.com/users/nomnomdom/gists{/gist_id}","starred_url":"https://api.github.com/users/nomnomdom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nomnomdom/subscriptions","organizations_url":"https://api.github.com/users/nomnomdom/orgs","repos_url":"https://api.github.com/users/nomnomdom/repos","events_url":"https://api.github.com/users/nomnomdom/events{/privacy}","received_events_url":"https://api.github.com/users/nomnomdom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-05T01:42:06Z","updated_at":"2015-06-05T07:29:57Z","closed_at":null,"body":"It looks like all the assemblies are marked as unsafe, which means the library can't be used in any .Net application, framework, or platform that requires safe code.  Is there any plan to fix this?\r\n\r\nFor example in Matrix we have:\r\n\r\n        public unsafe static double[,] ToDouble(this float[,] matrix)\r\n\r\nIt looks like this is used in several hundred places in Accord.Math alone.  Was this done for any particular reason?  Unsafe code gives trivial, if any, performance boosts as the compiler is pretty good at optimizing bounds checking.  It is also just ridiculously dangerous.\r\n"},"comment":{"url":"https://api.github.com/repos/accord-net/framework/issues/comments/109190714","html_url":"https://github.com/accord-net/framework/issues/106#issuecomment-109190714","issue_url":"https://api.github.com/repos/accord-net/framework/issues/106","id":109190714,"user":{"login":"cesarsouza","id":528455,"avatar_url":"https://avatars.githubusercontent.com/u/528455?v=3","gravatar_id":"","url":"https://api.github.com/users/cesarsouza","html_url":"https://github.com/cesarsouza","followers_url":"https://api.github.com/users/cesarsouza/followers","following_url":"https://api.github.com/users/cesarsouza/following{/other_user}","gists_url":"https://api.github.com/users/cesarsouza/gists{/gist_id}","starred_url":"https://api.github.com/users/cesarsouza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cesarsouza/subscriptions","organizations_url":"https://api.github.com/users/cesarsouza/orgs","repos_url":"https://api.github.com/users/cesarsouza/repos","events_url":"https://api.github.com/users/cesarsouza/events{/privacy}","received_events_url":"https://api.github.com/users/cesarsouza/received_events","type":"User","site_admin":false},"created_at":"2015-06-05T07:29:57Z","updated_at":"2015-06-05T07:29:57Z","body":"Hi there,\r\n\r\nUnfortunately, the compiler doesn't optimize bounds checks for multidimensional (i.e. [,]) matrices. Other code sections have been adapted from Fortran or C/C++ public domain algorithms that are not trivial to be rewritten without using pointers.\r\n\r\nIt should be possible, however, to exclude certain parts from the generated assemblies using compiler directives, but this would mean removing some functionality from the framework, or at least moving them to a different assembly. However, it wouldnt make sense in all the cases. For example, one part that absolutely needs pointers is the Imaging assembly. Image and video processing using .NET's System.Drawing cannot be done efficiently without using pointers. \r\n\r\nI will switch off the unsafe for Accord.Math and see how much effort would be necessary to replace the unsafe sections with safe counterparts and extra compiler directives. Thanks for registering the issue!"}}