(9230,17729,'2016-09-19 16:44:59','2016-09-19 20:44:59','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4.0 release.</p>\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4.0 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"New_Features_56\"></a>New Features</h5>\r\n\r\n<h6>Vector Fields</h6>\r\n<p>An example of how to render your data as a vector field has been provided in our examples which you can find <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway and gravity simulation. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a>.\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4.0','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 16:44:59','2016-09-19 20:44:59','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9231,17729,'2016-09-19 16:45:45','2016-09-19 20:45:45','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4.0 release.</p>\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4.0 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"New_Features_56\"></a>New Features</h5>\r\n\r\n<h6>Vector Fields</h6>\r\n<p>An example of how to render your data as a vector field has been provided in our examples which you can find <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway and gravity simulation. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a>.\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4.0','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 16:45:45','2016-09-19 20:45:45','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9232,17729,'2016-09-19 16:50:15','2016-09-19 20:50:15','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4.0 release.</p>\r\n<h5><a id=\"New_Features_56\"></a>New Features</h5>\r\n<h6>Vector Fields</h6>\r\n<p>An example of how to render your data as a vector field has been provided in our examples which you can find <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway and gravity simulation. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4.0 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4.0','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 16:50:15','2016-09-19 20:50:15','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9233,17729,'2016-09-19 16:51:04','2016-09-19 20:51:04','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4.0 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>An example of how to render your data as a vector field has been provided in our examples which you can find <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway and gravity simulation. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4.0 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4.0','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 16:51:04','2016-09-19 20:51:04','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9234,17729,'2016-09-19 16:51:56','2016-09-19 20:51:56','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4.0 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>An example of how to render your data as a vector field has been provided in our examples which you can find <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart renderables</h6>\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway and gravity simulation. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4.0 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4.0','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 16:51:56','2016-09-19 20:51:56','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9235,11,'2016-09-19 16:52:34','2016-09-19 20:52:34','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless.\r\nWe have added a function <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a> that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n<ul>\r\n<a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)/a>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is part of making the usage of sparse arrays seamless with regular arrays.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-19 16:52:34','2016-09-19 20:52:34','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9236,17729,'2016-09-19 16:53:01','2016-09-19 20:53:01','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4.0 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>An example of how to render your data as a vector field has been provided in our examples which you can find <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart renderables</h6>\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway and gravity simulation. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4.0 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4.0','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 16:53:01','2016-09-19 20:53:01','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9237,11,'2016-09-19 16:53:46','2016-09-19 20:53:46','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless.\r\nWe have added a function <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a> that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li style=\"list-style-type:none\"><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n<ul>\r\n<a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)/a>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is part of making the usage of sparse arrays seamless with regular arrays.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-19 16:53:46','2016-09-19 20:53:46','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9238,11,'2016-09-19 16:54:07','2016-09-19 20:54:07','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless.\r\nWe have added a function <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a> that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n<ul>\r\n<a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)/a>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is part of making the usage of sparse arrays seamless with regular arrays.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-19 16:54:07','2016-09-19 20:54:07','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9239,11,'2016-09-19 16:55:50','2016-09-19 20:55:50','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless.\r\nWe have added a function <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a> that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)/a>\r\n<ul>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is part of making the usage of sparse arrays seamless with regular arrays.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-19 16:55:50','2016-09-19 20:55:50','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9240,17729,'2016-09-19 17:00:14','2016-09-19 21:00:14','','julia','','inherit','open','closed','','julia','','','2016-09-19 17:00:14','2016-09-19 21:00:14','',9172,'http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif',0,'attachment','image/gif',0),(9241,17729,'2016-09-19 17:00:27','2016-09-19 21:00:27','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4.0 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>An example of how to render your data as a vector field has been provided in our examples which you can find <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart renderables</h6>\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4.0 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4.0','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 17:00:27','2016-09-19 21:00:27','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9242,11,'2016-09-19 17:09:04','2016-09-19 21:09:04','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless.\r\nWe have added a function <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a> that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)</a>\r\n<ul>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is part of making the usage of sparse arrays seamless with regular arrays.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-19 17:09:04','2016-09-19 21:09:04','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9244,18673,'2016-09-19 17:43:09','2016-09-19 21:43:09','','New Interpolation methods','Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.','inherit','open','closed','','approx1','','','2016-09-19 17:44:03','2016-09-19 21:44:03','',9166,'http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png',0,'attachment','image/png',0),(9245,18673,'2016-09-19 17:46:37','2016-09-19 21:46:37','','Capture','','inherit','open','closed','','capture','','','2016-09-19 17:46:37','2016-09-19 21:46:37','',9166,'http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png',0,'attachment','image/png',0),(9246,18673,'2016-09-19 18:02:08','2016-09-19 22:02:08','','com','','inherit','open','closed','','com','','','2016-09-19 18:02:08','2016-09-19 22:02:08','',9166,'http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png',0,'attachment','image/png',0),(9247,18673,'2016-09-19 18:06:56','2016-09-19 22:06:56','There are a number of  additions and updates to image based features in the new 3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods are:\r\n<ul>\r\n 	<li>AF_INTERP_LINEAR_COSINE</li>\r\n 	<li>AF_INTERP_CUBIC</li>\r\n</ul>\r\nfor 1-d functions and:\r\n<ul>\r\n 	<li>AF_INTERP_BILINEAR_COSINE</li>\r\n 	<li>AF_INTERP_BICUBIC</li>\r\n</ul>\r\nfor 2-d functions. The behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> Starting from raw data, linear interpolation, linear-cosine interpolation, to cubic interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can re-sample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolants further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nAnother addition to this release of ArrayFire are image moments. Image moments are weighted averages of pixels in an image which let us find out some useful properties of an image. A common use of image moments is to find the center of mass or area of some image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:default decode:true \">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\nArrayFire is always adding new methods to help you with accelerating your applications. We hope the new functions will be the vital tools that assist and inspire in your high performance applications!','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-19 18:06:56','2016-09-19 22:06:56','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9248,18673,'2016-09-19 18:09:10','2016-09-19 22:09:10','There are a number of  additions and updates to image based features in the new 3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods are:\r\n<ul>\r\n 	<li>AF_INTERP_LINEAR_COSINE</li>\r\n 	<li>AF_INTERP_CUBIC</li>\r\n</ul>\r\nfor 1-d functions and:\r\n<ul>\r\n 	<li>AF_INTERP_BILINEAR_COSINE</li>\r\n 	<li>AF_INTERP_BICUBIC</li>\r\n</ul>\r\nfor 2-d functions. The behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> Starting from raw data, linear interpolation, linear-cosine interpolation, to cubic interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can re-sample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolants further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nAnother addition to this release of ArrayFire are image moments. Image moments are weighted averages of pixels in an image which let us find out some useful properties of an image. A common use of image moments is to find the center of mass or area of some image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\nArrayFire is always adding new methods to help you with accelerating your applications. We hope the new functions will be the vital tools that assist and inspire in your high performance applications!','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-19 18:09:10','2016-09-19 22:09:10','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9249,11,'2016-09-19 19:33:53','2016-09-19 23:33:53','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored, hence reducing the size in memory. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless. We have added a function, <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a>, that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)</a>\r\n<ul>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is part of making the usage of sparse arrays seamless with regular arrays.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-19 19:33:53','2016-09-19 23:33:53','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9250,11,'2016-09-19 19:48:34','2016-09-19 23:48:34','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored, hence reducing the size in memory. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless. We have added a function, <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a>, that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)</a>\r\n<ul>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is inline with making the usage of sparse arrays seamless with regular arrays.\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\n<h4>Future Improvements</h4>\r\nWith the basic support for sparse arrays now complete, we can move forward to add more functionality that supports sparse arrays. Some of the features we are looking forwards to are:\r\n<ul>\r\n<li>Adding CSC support</li>\r\n<li>Storage format conversion between CSR, CSC, COO</li>\r\n<li>Matrix Multiplcation with CSC</li>\r\n<li>Sparse-Sparse Matrix Multiplcation (SPGEMM)</li>\r\n<li>Arithmetic operation support</li>\r\n</li>\r\n\r\nThe <a href=\"https://github.com/arrayfire/arrayfire\">ArrayFire</a> GitHub page is the place for all updates on features and improvements to ArrayFire. You can also add your requests for features you would like to see added.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-19 19:48:34','2016-09-19 23:48:34','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9251,11,'2016-09-19 19:54:19','2016-09-19 23:54:19','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored, hence reducing the size in memory. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless. We have added a function, <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a>, that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\nMore details can be found on the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse documentation for ArrayFire</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)</a>\r\n<ul>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is inline with making the usage of sparse arrays seamless with regular arrays.\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\n<h4>Future Improvements</h4>\r\nWith the basic support for sparse arrays now complete, we can move forward to add more functionality that supports sparse arrays. Some of the features we are looking forwards to are:\r\n<ul>\r\n<li>Adding CSC support</li>\r\n<li>Storage format conversion between CSR, CSC, COO</li>\r\n<li>Matrix Multiplcation with CSC</li>\r\n<li>Sparse-Sparse Matrix Multiplcation (SPGEMM)</li>\r\n<li>Arithmetic operation support</li>\r\n</li>\r\n\r\nThe <a href=\"https://github.com/arrayfire/arrayfire\">ArrayFire</a> GitHub page is the place for all updates on features and improvements to ArrayFire. You can also add your requests for features you would like to see added.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-19 19:54:19','2016-09-19 23:54:19','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9252,17728,'2016-09-21 22:16:45','2016-09-22 02:16:45','ArrayFire uses <a href=\"http://sandbox.arrayfire.com/performance-of-arrayfire-jit-code-generation/\">Just In Time</a> compilation to combine many light weight functions into a single kernel launch. This along with our <a href=\"http://arrayfire.org/docs/group__arrayfire__func.htm\">easy-to-use API</a> allows users to not only quickly prototype their algorithms, but also get the best out of the underlying hardware.\r\n\r\nThis feature has been a favorite among our users in the domains of finance and scientific simulation.\r\n\r\nThat said, ArrayFire v3.3 and earlier had a few limitations. Namely:\r\n<ul class=\"org-ul\">\r\n 	<li>Multiple outputs with inter-dependent variables were generating multiple kernels.</li>\r\n 	<li>The number of operations per kernel was fairly limited by default.</li>\r\n</ul>\r\nIn the latest release of ArrayFire, we addressed these issues to get some pretty impressive numbers.\r\n\r\nIn the rest of the post, we demonstrate the performance improvements using our <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/financial/black_scholes_options.cpp\">BlackScholes example</a>. For this particular example, the improvements for the CUDA backend were <b>~8x</b> and OpenCL backend were between <b>~5x</b>.\r\n\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Performance Comparison between v3.4 and v3.3[/custom_headline]\r\n<div id=\"outline-container-sec-1\" class=\"outline-2\">\r\n<div id=\"text-1\" class=\"outline-text-2\">\r\n\r\n<a href=\"https://en.wikipedia.org/wiki/Black%25E2%2580%2593Scholes_model\">BlackScholes</a> is a commonly used mathematical model in financial markets.\r\n\r\nIt takes the following 5 inputs and generates 2 outputs.\r\n\r\nThe code to implement this model in ArrayFire can be seen below.\r\n<div class=\"org-src-container\">\r\n<pre class=\"src src-C++\">array cnd(array x)\r\n{\r\n    // constants\r\n    const float a1 =  0.254829592;\r\n    const float a2 = -0.284496736;\r\n    const float a3 =  1.421413741;\r\n    const float a4 = -1.453152027;\r\n    const float a5 =  1.061405429;\r\n    const float p  =  0.3275911;\r\n    const float sqrt2 = sqrt(2.0);\r\n\r\n    // Save the sign of x\r\n    array xSign = sign(x);\r\n\r\n    x = abs(x) / sqrt2;\r\n\r\n    // A & S formula 7.1.26\r\n    array t = 1.0f / (1.0f + p*x);\r\n    array y = 1.0f + 0.5f * (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);\r\n\r\n    return xSign * y + !xSign * (1 - y); // equivalent of (x >= 0) ? y : (1 - y);\r\n}\r\n\r\nstatic void black_scholes(array& C, array& P,\r\n                          const array& S, const array& X,\r\n                          const array& R, const array& V,\r\n                          const array& T)\r\n{\r\n    // Inputs:\r\n    // S: Stock price\r\n    // X: Strike price\r\n    // R: Risk free rate of interest\r\n    // V: Volatility\r\n    // T: Time to maturity\r\n\r\n    // Outputs:\r\n    // C: Call option\r\n    // P: Put option\r\n\r\n    array d1 = log(S / X);\r\n    d1 = d1 + (R + (V*V)*0.5) * T;\r\n    d1 = d1 / (V*sqrt(T));\r\n\r\n    array d2 = d1 - (V*sqrt(T));\r\n\r\n    array cnd_d1 = cnd(d1);\r\n    array cnd_d2 = cnd(d2);\r\n\r\n    C = S * cnd_d1  - (X * exp((-R)*T) * cnd_d2);\r\n    P = X * exp((-R)*T) * (1 - cnd_d2) - (S * (1 - cnd_d1));\r\n}\r\n</pre>\r\n</div>\r\nThe <code>black_scholes</code> function contains a long chain of operations and generates two outputs. In older versions of ArrayFire, the Just-In-Time compiler of arrayfire was splitting up this single function call to multiple kernels.\r\n\r\nWe solved this in the latest release by:\r\n<ul class=\"org-ul\">\r\n 	<li>Enabling <code>af::eval</code> to hint ArrayFire\'s JIT compiler to combine kernels generating multiple outputs.</li>\r\n 	<li>Changing the heuristics to increase the number of operations per kernel.</li>\r\n</ul>\r\n<div class=\"org-src-container\">\r\n<pre class=\"src src-C++\">black_scholes(C, P, S, X, R, V, T);\r\neval(C, P); // Only change required for v3.4\r\n</pre>\r\n</div>\r\nThese changes resulted in dramatic performance improvements seen below. The following graph compares the number of call and put options being calculated per second on v3.3 and v3.4.\r\n\r\n&nbsp;\r\n\r\n<iframe width=\"650\" height=\"400\" seamless=\"\" frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=927257953&amp;format=interactive\">\r\n</iframe>\r\n\r\n&nbsp;\r\n\r\nAs we can see, the performance has improved significantly. The absolute time taken when to calculate 2 million options is show below.\r\n\r\n&nbsp;\r\n\r\n<iframe width=\"513.5\" height=\"104.0141666666666\" seamless=\"\" frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=1295781261&amp;format=interactive\"></iframe>\r\n\r\nNote:\r\n<ul class=\"org-ul\">\r\n 	<li>The additional gains made by CUDA are because of a <a href=\"https://github.com/arrayfire/arrayfire/pull/1534\">separate issue</a> involving CUDA JIT that was fixed.</li>\r\n 	<li>Only 24 threads of the 32 available were used for the Xeon CPU.</li>\r\n</ul>\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Performance Comparison to Native CUDA[/custom_headline]\r\n\r\n</div>\r\n</div>\r\n<div id=\"outline-container-sec-2\" class=\"outline-2\">\r\n<div id=\"text-2\" class=\"outline-text-2\">\r\n\r\nTo see how close we can get to the peak performance, we compared the performance of ArrayFire and CUDA on the new GTX 1080.\r\n\r\nTo do this we built ArrayFire 3.4 using the CUDA 8 RC and compared its performance with that of the example provided in <a href=\"http://docs.nvidia.com/cuda/cuda-samples/#black-scholes-option-pricing\">CUDA Samples</a>.\r\n\r\nThe results of this benchmark can be seen below.\r\n\r\n<iframe width=\"655.1414131325375\" height=\"323.5\" seamless=\"\" frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=256763192&amp;format=interactive\"></iframe>\r\n\r\nThe results indicate ArrayFire v3.4 performs identical to the native kernel at larger simulation sizes, but there is a constant overhead causing issues at smaller sizes. This is one of the issues we want to address in future releases.\r\n\r\nNote: The <code>black_scholes</code> function had to be changed slightly to be similar to the sample provided by CUDA.\r\n\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Coming Soon[/custom_headline]\r\n\r\n</div>\r\n</div>\r\n<div id=\"outline-container-sec-3\" class=\"outline-2\">\r\n<div id=\"text-3\" class=\"outline-text-2\">\r\n\r\nWhile the new improvements to the JIT engine in ArrayFire can seamlessly generate kernels that perform close to handwritten native kernels on GPUs, there is room for improvement at smaller sizes. To see what lies ahead for ArrayFire JIT, please check out <a href=\"https://github.com/arrayfire/arrayfire/issues/1401\">this github issue</a>.\r\n\r\n</div>\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Download[/custom_headline]\r\n\r\nArrayFire v3.4 can be downloaded from these locations:\r\n<ul>\r\n 	<li><a href=\"http://sandbox.arrayfire.com/download/\">Binaries</a></li>\r\n 	<li><a href=\"https://github.com/arrayfire\">Source code</a></li>\r\n</ul>\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Community[/custom_headline]\r\n\r\nArrayFire is continually improving through the addition of new JIT enhancements. We welcome your feedback:\r\n<ul>\r\n 	<li>General discussion forums on the <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">ArrayFire Google Group</a></li>\r\n 	<li>Live discussion chat on the <a href=\"https://gitter.im/arrayfire/arrayfire?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\">ArrayFire Gitter</a></li>\r\n 	<li>Issue reports on the <a href=\"https://github.com/arrayfire/arrayfire/issues\">ArrayFire GitHub</a></li>\r\n</ul>\r\nFinally, as you find success with ArrayFire, we invite you to contribute a post to this blog to share with the broader community. Email <a href=\"mailto:scott@arrayfire.com\">scott@arrayfire.com</a> to contribute to this blog.\r\n\r\n&nbsp;\r\n\r\n</div>','Performance Improvements to JIT in ArrayFire v3.4','','publish','open','closed','','performance-improvements-to-jit-in-arrayfire-v3-4','','','2016-09-22 11:59:23','2016-09-22 15:59:23','',0,'http://sandbox.arrayfire.com/?p=9252',0,'post','',0),(9253,17728,'2016-09-19 20:27:43','2016-09-20 00:27:43','<p>\r\nAs some of you may be aware, ArrayFire uses <a href=\"http://sandbox.arrayfire.com/performance-of-arrayfire-jit-code-generation/\">Just In Time</a> compilation to combine many light weight functions into a single kernel launch.\r\nThis along with our <a href=\"http://arrayfire.org/docs/group__arrayfire__func.htm\">easy-to-use API</a> allows users to not only quickly prototype their algorithms, but also get the best out of the underlying hardware.\r\n</p>\r\n\r\n<p>\r\nThis feature has been a old favorite among our users in the domains of finance and scientific simulation.\r\n</p>\r\n\r\n<p>\r\nThat said, ArrayFire v3.3 and earlier had a few limitations. Namely:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Multiple outputs with inter-dependent variables were generating multiple kernels.\r\n</li>\r\n<li>The number of operations per kernel was fairly limited by default.\r\n</li>\r\n</ul>\r\n\r\n<p>\r\nIn the latest release of ArrayFire, we addressed these issues to get some pretty impressive numbers.\r\n</p>\r\n\r\n<p>\r\nIn the rest of the post, we use our <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/financial/black_scholes_options.cpp\">BlackScholes example</a>, a commonly used mathematical model in finance, to show case the improvements.\r\n</p>\r\n\r\n<div id=\"outline-container-sec-1\" class=\"outline-2\">\r\n<h2 id=\"sec-1\">Performance Comparison to v3.3</h2>\r\n<div class=\"outline-text-2\" id=\"text-1\">\r\n<p>\r\nBlackScholes model takes the following 5 inputs\r\n</p>\r\n\r\n<p>\r\nInputs:\r\n</p>\r\n\r\n<ul class=\"org-ul\">\r\n<li><code>S</code>: Stock price\r\n</li>\r\n<li><code>X</code>: Strike price\r\n</li>\r\n<li><code>R</code>: Risk free rate of interest\r\n</li>\r\n<li><code>V</code>: Volatility\r\n</li>\r\n<li><code>T</code>: Time to maturity\r\n</li>\r\n</ul>\r\n\r\n<p>\r\nand performs a long chain of element wise mathematical operations to generate the following 2 outputs.\r\n</p>\r\n\r\n<p>\r\nOutputs:\r\n</p>\r\n\r\n<ul class=\"org-ul\">\r\n<li><code>C</code>: Call option\r\n</li>\r\n<li><code>P</code>: Put option\r\n</li>\r\n</ul>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">array cnd(array x)\r\n{\r\n    // constants\r\n    const float a1 =  0.254829592;\r\n    const float a2 = -0.284496736;\r\n    const float a3 =  1.421413741;\r\n    const float a4 = -1.453152027;\r\n    const float a5 =  1.061405429;\r\n    const float p  =  0.3275911;\r\n    const float sqrt2 = sqrt(2.0);\r\n\r\n    // Save the sign of x\r\n    array xSign = sign(x);\r\n\r\n    x = abs(x) / sqrt2;\r\n\r\n    // A&amp;S formula 7.1.26\r\n    array t = 1.0f / (1.0f + p*x);\r\n    array y = 1.0f + 0.5f * (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);\r\n\r\n    return xSign * y + !xSign * (1 - y); // equivalent of (x &gt;= 0) ? y : (1 - y);\r\n}\r\n\r\nstatic void black_scholes(array&amp; C, array&amp; P,\r\n                          const array&amp; S, const array&amp; X,\r\n                          const array&amp; R, const array&amp; V,\r\n                          const array&amp; T)\r\n{\r\n    // This function computes the call and put option prices based on\r\n    // Black-Scholes Model\r\n\r\n    // S = Underlying stock price\r\n    // X = Strike Price\r\n    // R = Risk free rate of interest\r\n    // V = Volatility\r\n    // T = Time to maturity\r\n\r\n    array d1 = log(S / X);\r\n    d1 = d1 + (R + (V*V)*0.5) * T;\r\n    d1 = d1 / (V*sqrt(T));\r\n\r\n    array d2 = d1 - (V*sqrt(T));\r\n\r\n    array cnd_d1 = cnd(d1);\r\n    array cnd_d2 = cnd(d2);\r\n\r\n    C = S * cnd_d1  - (X * exp((-R)*T) * cnd_d2);\r\n    P = X * exp((-R)*T) * (1 - cnd_d2) - (S * (1 - cnd_d1));\r\n}\r\n</pre>\r\n</div>\r\n\r\n<p>\r\nDue to the nature of the model (both long chain of operations and multiple outputs), older versions of arrayfire were splitting up this single function call to multiple kernels.\r\n</p>\r\n\r\n<p>\r\nTo solve this issue, in the latest we\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Enabled <code>af::eval</code> to hint ArrayFire\'s JIT compiler to combine inputs\r\n</li>\r\n<li>Changed the heuristics to increase the number of operations per kernel\r\n</li>\r\n</ul>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">black_scholes(C, P, S, X, R, V, T);\r\neval(C, P); // Only change required for v3.4\r\n</pre>\r\n</div>\r\n\r\n<p>\r\nThese changes resulted in dramatic performance improvements seen below.\r\n</p>\r\n\r\n<iframe width=\"574.52125\" height=\"355.25250000000005\" seamless frameborder=\"0\" scrolling=\"no\"\r\nsrc=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=927257953&amp;format=interactive\">\r\n</iframe>\r\n</div>\r\n</div>\r\n</div>','Performance improvements to JIT in ArrayFire 3.4','','inherit','closed','closed','','9252-revision-v1','','','2016-09-19 20:27:43','2016-09-20 00:27:43','',9252,'http://sandbox.arrayfire.com/9252-revision-v1/',0,'revision','',0),(9254,18673,'2016-09-19 20:50:26','2016-09-20 00:50:26','','approx1','','inherit','open','closed','','approx1-2','','','2016-09-19 20:50:26','2016-09-20 00:50:26','',9166,'http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1-1.png',0,'attachment','image/png',0),(9256,17728,'2016-09-19 22:43:46','2016-09-20 02:43:46','<p>\r\nAs some of you may be aware, ArrayFire uses <a href=\"http://sandbox.arrayfire.com/performance-of-arrayfire-jit-code-generation/\">Just In Time</a> compilation to combine many light weight functions into a single kernel launch.\r\nThis along with our <a href=\"http://arrayfire.org/docs/group__arrayfire__func.htm\">easy-to-use API</a> allows users to not only quickly prototype their algorithms, but also get the best out of the underlying hardware.\r\n</p>\r\n\r\n<p>\r\nThis feature has been a old favorite among our users in the domains of finance and scientific simulation.\r\n</p>\r\n\r\n<p>\r\nThat said, ArrayFire v3.3 and earlier had a few limitations. Namely:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Multiple outputs with inter-dependent variables were generating multiple kernels.\r\n</li>\r\n<li>The number of operations per kernel was fairly limited by default.\r\n</li>\r\n</ul>\r\n\r\n<p>\r\nIn the latest release of ArrayFire, we addressed these issues to get some pretty impressive numbers.\r\n</p>\r\n\r\n<p>\r\nIn the rest of the post, we demonstrate the performance improvements using our <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/financial/black_scholes_options.cpp\">BlackScholes example</a>. For this particular example, the improvements for the CUDA backend were <b>~8x</b> and OpenCL backend were between <b>~5x</b>.\r\n</p>\r\n\r\n<div id=\"outline-container-sec-1\" class=\"outline-2\">\r\n<h2 id=\"sec-1\">Performance Comparison to v3.3</h2>\r\n<div class=\"outline-text-2\" id=\"text-1\">\r\n<p>\r\n<a href=\"https://en.wikipedia.org/wiki/Black%25E2%2580%2593Scholes_model\">BlackScholes</a> is a commonly used mathematical model in financial markets.\r\n</p>\r\n\r\n<p>\r\nIt takes the following 5 inputs and generates 2 outputs.\r\n</p>\r\n\r\n<p>\r\nThe code to implement this model in arrayfire can be seen below.\r\n</p>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">array cnd(array x)\r\n{\r\n    // constants\r\n    const float a1 =  0.254829592;\r\n    const float a2 = -0.284496736;\r\n    const float a3 =  1.421413741;\r\n    const float a4 = -1.453152027;\r\n    const float a5 =  1.061405429;\r\n    const float p  =  0.3275911;\r\n    const float sqrt2 = sqrt(2.0);\r\n\r\n    // Save the sign of x\r\n    array xSign = sign(x);\r\n\r\n    x = abs(x) / sqrt2;\r\n\r\n    // A&amp;S formula 7.1.26\r\n    array t = 1.0f / (1.0f + p*x);\r\n    array y = 1.0f + 0.5f * (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);\r\n\r\n    return xSign * y + !xSign * (1 - y); // equivalent of (x &gt;= 0) ? y : (1 - y);\r\n}\r\n\r\nstatic void black_scholes(array&amp; C, array&amp; P,\r\n                          const array&amp; S, const array&amp; X,\r\n                          const array&amp; R, const array&amp; V,\r\n                          const array&amp; T)\r\n{\r\n    // Inputs:\r\n    // S: Stock price\r\n    // X: Strike price\r\n    // R: Risk free rate of interest\r\n    // V: Volatility\r\n    // T: Time to maturity\r\n\r\n    // Outputs:\r\n    // C: Call option\r\n    // P: Put option\r\n\r\n    array d1 = log(S / X);\r\n    d1 = d1 + (R + (V*V)*0.5) * T;\r\n    d1 = d1 / (V*sqrt(T));\r\n\r\n    array d2 = d1 - (V*sqrt(T));\r\n\r\n    array cnd_d1 = cnd(d1);\r\n    array cnd_d2 = cnd(d2);\r\n\r\n    C = S * cnd_d1  - (X * exp((-R)*T) * cnd_d2);\r\n    P = X * exp((-R)*T) * (1 - cnd_d2) - (S * (1 - cnd_d1));\r\n}\r\n</pre>\r\n</div>\r\n\r\n<p>\r\nThe <code>black_scholes</code> function contains a long chain of operations and generates two outputs. In older versions of ArrayFire, the Just-In-Time compiler of arrayfire was splitting up this single function call to multiple kernels.\r\n</p>\r\n\r\n<p>\r\nWe solved this in the latest release by:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Enabling <code>af::eval</code> to hint ArrayFire\'s JIT compiler to combine inputs.\r\n</li>\r\n<li>Changing the heuristics to increase the number of operations per kernel.\r\n</li>\r\n</ul>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">black_scholes(C, P, S, X, R, V, T);\r\neval(C, P); // Only change required for v3.4\r\n</pre>\r\n</div>\r\n\r\n\r\n\r\nThese changes resulted in dramatic performance improvements seen below. The following graph compares the number of call and put options being calculated per second on v3.3.2 and v3.4.0.\r\n\r\n<br>\r\n\r\n<iframe width=\"650\" height=\"400\" seamless frameborder=\"0\" scrolling=\"no\"\r\nsrc=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=927257953&amp;format=interactive\">\r\n</iframe>\r\n\r\n<br>\r\n\r\nAs we can see, the performance has improved significantly. The absolute time taken when to calculate 2 million options is show below.\r\n\r\n<br>\r\n<br>\r\n\r\n<iframe width=\"513.5\" height=\"104.0141666666666\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=1295781261&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nNote:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>The additional gains made by CUDA are because of a <a href=\"https://github.com/arrayfire/arrayfire/pull/1534\">separate issue</a> involving CUDA JIT that was fixed.\r\n</li>\r\n<li>Only 24 threads of the 32 available were used for the Xeon CPU.\r\n</li>\r\n</ul>\r\n</div>\r\n</div>\r\n\r\n<div id=\"outline-container-sec-2\" class=\"outline-2\">\r\n<h2 id=\"sec-2\">Performance Comparison to Native CUDA</h2>\r\n<div class=\"outline-text-2\" id=\"text-2\">\r\n<p>\r\nTo see how close we can get to the peak performance, we compared the performance of ArrayFire and CUDA on the new GTX 1080.\r\n</p>\r\n\r\n<p>\r\nTo do this we built ArrayFire 3.4.0 using the CUDA 8 RC and compared its performance with that of the example provided in <a href=\"http://docs.nvidia.com/cuda/cuda-samples/#black-scholes-option-pricing\">CUDA Samples</a>.\r\n</p>\r\n\r\n\r\nThe results of this benchmark can be seen below.\r\n\r\n<iframe width=\"655.1414131325375\" height=\"323.5\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=256763192&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nThe results indicate ArrayFire v3.4 performs identical to the native kernel at larger simulation sizes, but there is a constant overhead causing issues at smaller sizes. This is one of the issues we want to address in future releases.\r\n</p>\r\n\r\n<p>\r\nNote: The <code>black_scholes</code> function had to be changed slightly as shown below to be similar to the sample provided by CUDA.\r\n</p>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">static void black_scholes(array&amp; C, array&amp; P,\r\n                          const array&amp; S, const float X,\r\n                          const array&amp; R, const float V,\r\n                          const array&amp; T)\r\n{\r\n   // The rest is same as shown above.\r\n}\r\n</pre>\r\n</div>\r\n</div>\r\n</div>\r\n\r\n\r\n<div id=\"outline-container-sec-3\" class=\"outline-2\">\r\n<h2 id=\"sec-3\">Conclusion</h2>\r\n<div class=\"outline-text-2\" id=\"text-3\">\r\n<p>\r\nThe new improvements to the JIT engine in ArrayFire can seamlessly generate kernels that perform close to handwritten native kernels on GPUs. There is still scope for improvements at smaller sizes. To see what lies ahead for our Just-In-Time compiler, please check out <a href=\"https://github.com/arrayfire/arrayfire/issues/1401\">this github issue</a>.\r\n</p>\r\n</div>\r\n</div>\r\n</div>','Performance improvements to JIT in ArrayFire 3.4','','inherit','closed','closed','','9252-revision-v1','','','2016-09-19 22:43:46','2016-09-20 02:43:46','',9252,'http://sandbox.arrayfire.com/9252-revision-v1/',0,'revision','',0),(9257,17728,'2016-09-19 22:47:26','2016-09-20 02:47:26','<p>\r\nArrayFire uses <a href=\"http://sandbox.arrayfire.com/performance-of-arrayfire-jit-code-generation/\">Just In Time</a> compilation to combine many light weight functions into a single kernel launch. This along with our <a href=\"http://arrayfire.org/docs/group__arrayfire__func.htm\">easy-to-use API</a> allows users to not only quickly prototype their algorithms, but also get the best out of the underlying hardware.\r\n</p>\r\n\r\n<p>\r\nThis feature has been a favorite among our users in the domains of finance and scientific simulation.\r\n</p>\r\n\r\n<p>\r\nThat said, ArrayFire v3.3 and earlier had a few limitations. Namely:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Multiple outputs with inter-dependent variables were generating multiple kernels.\r\n</li>\r\n<li>The number of operations per kernel was fairly limited by default.\r\n</li>\r\n</ul>\r\n\r\n<p>\r\nIn the latest release of ArrayFire, we addressed these issues to get some pretty impressive numbers.\r\n</p>\r\n\r\n<p>\r\nIn the rest of the post, we demonstrate the performance improvements using our <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/financial/black_scholes_options.cpp\">BlackScholes example</a>. For this particular example, the improvements for the CUDA backend were <b>~8x</b> and OpenCL backend were between <b>~5x</b>.\r\n</p>\r\n\r\n<div id=\"outline-container-sec-1\" class=\"outline-2\">\r\n<h2 id=\"sec-1\">Performance Comparison to v3.3</h2>\r\n<div class=\"outline-text-2\" id=\"text-1\">\r\n<p>\r\n<a href=\"https://en.wikipedia.org/wiki/Black%25E2%2580%2593Scholes_model\">BlackScholes</a> is a commonly used mathematical model in financial markets.\r\n</p>\r\n\r\n<p>\r\nIt takes the following 5 inputs and generates 2 outputs.\r\n</p>\r\n\r\n<p>\r\nThe code to implement this model in arrayfire can be seen below.\r\n</p>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">array cnd(array x)\r\n{\r\n    // constants\r\n    const float a1 =  0.254829592;\r\n    const float a2 = -0.284496736;\r\n    const float a3 =  1.421413741;\r\n    const float a4 = -1.453152027;\r\n    const float a5 =  1.061405429;\r\n    const float p  =  0.3275911;\r\n    const float sqrt2 = sqrt(2.0);\r\n\r\n    // Save the sign of x\r\n    array xSign = sign(x);\r\n\r\n    x = abs(x) / sqrt2;\r\n\r\n    // A&amp;S formula 7.1.26\r\n    array t = 1.0f / (1.0f + p*x);\r\n    array y = 1.0f + 0.5f * (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);\r\n\r\n    return xSign * y + !xSign * (1 - y); // equivalent of (x &gt;= 0) ? y : (1 - y);\r\n}\r\n\r\nstatic void black_scholes(array&amp; C, array&amp; P,\r\n                          const array&amp; S, const array&amp; X,\r\n                          const array&amp; R, const array&amp; V,\r\n                          const array&amp; T)\r\n{\r\n    // Inputs:\r\n    // S: Stock price\r\n    // X: Strike price\r\n    // R: Risk free rate of interest\r\n    // V: Volatility\r\n    // T: Time to maturity\r\n\r\n    // Outputs:\r\n    // C: Call option\r\n    // P: Put option\r\n\r\n    array d1 = log(S / X);\r\n    d1 = d1 + (R + (V*V)*0.5) * T;\r\n    d1 = d1 / (V*sqrt(T));\r\n\r\n    array d2 = d1 - (V*sqrt(T));\r\n\r\n    array cnd_d1 = cnd(d1);\r\n    array cnd_d2 = cnd(d2);\r\n\r\n    C = S * cnd_d1  - (X * exp((-R)*T) * cnd_d2);\r\n    P = X * exp((-R)*T) * (1 - cnd_d2) - (S * (1 - cnd_d1));\r\n}\r\n</pre>\r\n</div>\r\n\r\n<p>\r\nThe <code>black_scholes</code> function contains a long chain of operations and generates two outputs. In older versions of ArrayFire, the Just-In-Time compiler of arrayfire was splitting up this single function call to multiple kernels.\r\n</p>\r\n\r\n<p>\r\nWe solved this in the latest release by:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Enabling <code>af::eval</code> to hint ArrayFire\'s JIT compiler to combine inputs.\r\n</li>\r\n<li>Changing the heuristics to increase the number of operations per kernel.\r\n</li>\r\n</ul>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">black_scholes(C, P, S, X, R, V, T);\r\neval(C, P); // Only change required for v3.4\r\n</pre>\r\n</div>\r\n\r\n\r\n\r\nThese changes resulted in dramatic performance improvements seen below. The following graph compares the number of call and put options being calculated per second on v3.3.2 and v3.4.0.\r\n\r\n<br>\r\n\r\n<iframe width=\"650\" height=\"400\" seamless frameborder=\"0\" scrolling=\"no\"\r\nsrc=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=927257953&amp;format=interactive\">\r\n</iframe>\r\n\r\n<br>\r\n\r\nAs we can see, the performance has improved significantly. The absolute time taken when to calculate 2 million options is show below.\r\n\r\n<br>\r\n<br>\r\n\r\n<iframe width=\"513.5\" height=\"104.0141666666666\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=1295781261&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nNote:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>The additional gains made by CUDA are because of a <a href=\"https://github.com/arrayfire/arrayfire/pull/1534\">separate issue</a> involving CUDA JIT that was fixed.\r\n</li>\r\n<li>Only 24 threads of the 32 available were used for the Xeon CPU.\r\n</li>\r\n</ul>\r\n</div>\r\n</div>\r\n\r\n<div id=\"outline-container-sec-2\" class=\"outline-2\">\r\n<h2 id=\"sec-2\">Performance Comparison to Native CUDA</h2>\r\n<div class=\"outline-text-2\" id=\"text-2\">\r\n<p>\r\nTo see how close we can get to the peak performance, we compared the performance of ArrayFire and CUDA on the new GTX 1080.\r\n</p>\r\n\r\n<p>\r\nTo do this we built ArrayFire 3.4.0 using the CUDA 8 RC and compared its performance with that of the example provided in <a href=\"http://docs.nvidia.com/cuda/cuda-samples/#black-scholes-option-pricing\">CUDA Samples</a>.\r\n</p>\r\n\r\n\r\nThe results of this benchmark can be seen below.\r\n\r\n<iframe width=\"655.1414131325375\" height=\"323.5\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=256763192&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nThe results indicate ArrayFire v3.4 performs identical to the native kernel at larger simulation sizes, but there is a constant overhead causing issues at smaller sizes. This is one of the issues we want to address in future releases.\r\n</p>\r\n\r\n<p>\r\nNote: The <code>black_scholes</code> function had to be changed slightly as shown below to be similar to the sample provided by CUDA.\r\n</p>\r\n</div>\r\n</div>\r\n\r\n<div id=\"outline-container-sec-3\" class=\"outline-2\">\r\n<h2 id=\"sec-3\">Conclusion</h2>\r\n<div class=\"outline-text-2\" id=\"text-3\">\r\n<p>\r\nThe new improvements to the JIT engine in ArrayFire can seamlessly generate kernels that perform close to handwritten native kernels on GPUs. There is still scope for improvements at smaller sizes. To see what lies ahead for our Just-In-Time compiler, please check out <a href=\"https://github.com/arrayfire/arrayfire/issues/1401\">this github issue</a>.\r\n</p>\r\n</div>\r\n</div>\r\n</div>\r\n','Performance improvements to JIT in ArrayFire 3.4','','inherit','closed','closed','','9252-revision-v1','','','2016-09-19 22:47:26','2016-09-20 02:47:26','',9252,'http://sandbox.arrayfire.com/9252-revision-v1/',0,'revision','',0),(9258,17728,'2016-09-19 22:51:23','2016-09-20 02:51:23','<p>\r\nArrayFire uses <a href=\"http://sandbox.arrayfire.com/performance-of-arrayfire-jit-code-generation/\">Just In Time</a> compilation to combine many light weight functions into a single kernel launch. This along with our <a href=\"http://arrayfire.org/docs/group__arrayfire__func.htm\">easy-to-use API</a> allows users to not only quickly prototype their algorithms, but also get the best out of the underlying hardware.\r\n</p>\r\n\r\n<p>\r\nThis feature has been a favorite among our users in the domains of finance and scientific simulation.\r\n</p>\r\n\r\n<p>\r\nThat said, ArrayFire v3.3 and earlier had a few limitations. Namely:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Multiple outputs with inter-dependent variables were generating multiple kernels.\r\n</li>\r\n<li>The number of operations per kernel was fairly limited by default.\r\n</li>\r\n</ul>\r\n\r\n<p>\r\nIn the latest release of ArrayFire, we addressed these issues to get some pretty impressive numbers.\r\n</p>\r\n\r\n<p>\r\nIn the rest of the post, we demonstrate the performance improvements using our <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/financial/black_scholes_options.cpp\">BlackScholes example</a>. For this particular example, the improvements for the CUDA backend were <b>~8x</b> and OpenCL backend were between <b>~5x</b>.\r\n</p>\r\n\r\n<div id=\"outline-container-sec-1\" class=\"outline-2\">\r\n<h3 id=\"sec-1\">Performance Comparison to v3.3</h3>\r\n<div class=\"outline-text-2\" id=\"text-1\">\r\n<p>\r\n<a href=\"https://en.wikipedia.org/wiki/Black%25E2%2580%2593Scholes_model\">BlackScholes</a> is a commonly used mathematical model in financial markets.\r\n</p>\r\n\r\n<p>\r\nIt takes the following 5 inputs and generates 2 outputs.\r\n</p>\r\n\r\n<p>\r\nThe code to implement this model in arrayfire can be seen below.\r\n</p>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">array cnd(array x)\r\n{\r\n    // constants\r\n    const float a1 =  0.254829592;\r\n    const float a2 = -0.284496736;\r\n    const float a3 =  1.421413741;\r\n    const float a4 = -1.453152027;\r\n    const float a5 =  1.061405429;\r\n    const float p  =  0.3275911;\r\n    const float sqrt2 = sqrt(2.0);\r\n\r\n    // Save the sign of x\r\n    array xSign = sign(x);\r\n\r\n    x = abs(x) / sqrt2;\r\n\r\n    // A&amp;S formula 7.1.26\r\n    array t = 1.0f / (1.0f + p*x);\r\n    array y = 1.0f + 0.5f * (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);\r\n\r\n    return xSign * y + !xSign * (1 - y); // equivalent of (x &gt;= 0) ? y : (1 - y);\r\n}\r\n\r\nstatic void black_scholes(array&amp; C, array&amp; P,\r\n                          const array&amp; S, const array&amp; X,\r\n                          const array&amp; R, const array&amp; V,\r\n                          const array&amp; T)\r\n{\r\n    // Inputs:\r\n    // S: Stock price\r\n    // X: Strike price\r\n    // R: Risk free rate of interest\r\n    // V: Volatility\r\n    // T: Time to maturity\r\n\r\n    // Outputs:\r\n    // C: Call option\r\n    // P: Put option\r\n\r\n    array d1 = log(S / X);\r\n    d1 = d1 + (R + (V*V)*0.5) * T;\r\n    d1 = d1 / (V*sqrt(T));\r\n\r\n    array d2 = d1 - (V*sqrt(T));\r\n\r\n    array cnd_d1 = cnd(d1);\r\n    array cnd_d2 = cnd(d2);\r\n\r\n    C = S * cnd_d1  - (X * exp((-R)*T) * cnd_d2);\r\n    P = X * exp((-R)*T) * (1 - cnd_d2) - (S * (1 - cnd_d1));\r\n}\r\n</pre>\r\n</div>\r\n\r\n<p>\r\nThe <code>black_scholes</code> function contains a long chain of operations and generates two outputs. In older versions of ArrayFire, the Just-In-Time compiler of arrayfire was splitting up this single function call to multiple kernels.\r\n</p>\r\n\r\n<p>\r\nWe solved this in the latest release by:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Enabling <code>af::eval</code> to hint ArrayFire\'s JIT compiler to combine inputs.\r\n</li>\r\n<li>Changing the heuristics to increase the number of operations per kernel.\r\n</li>\r\n</ul>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">black_scholes(C, P, S, X, R, V, T);\r\neval(C, P); // Only change required for v3.4\r\n</pre>\r\n</div>\r\n\r\n\r\n\r\nThese changes resulted in dramatic performance improvements seen below. The following graph compares the number of call and put options being calculated per second on v3.3.2 and v3.4.0.\r\n\r\n<br>\r\n\r\n<iframe width=\"650\" height=\"400\" seamless frameborder=\"0\" scrolling=\"no\"\r\nsrc=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=927257953&amp;format=interactive\">\r\n</iframe>\r\n\r\n<br>\r\n\r\nAs we can see, the performance has improved significantly. The absolute time taken when to calculate 2 million options is show below.\r\n\r\n<br>\r\n<br>\r\n\r\n<iframe width=\"513.5\" height=\"104.0141666666666\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=1295781261&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nNote:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>The additional gains made by CUDA are because of a <a href=\"https://github.com/arrayfire/arrayfire/pull/1534\">separate issue</a> involving CUDA JIT that was fixed.\r\n</li>\r\n<li>Only 24 threads of the 32 available were used for the Xeon CPU.\r\n</li>\r\n</ul>\r\n</div>\r\n</div>\r\n\r\n<div id=\"outline-container-sec-2\" class=\"outline-2\">\r\n<h3 id=\"sec-2\">Performance Comparison to Native CUDA</h3>\r\n<div class=\"outline-text-2\" id=\"text-2\">\r\n<p>\r\nTo see how close we can get to the peak performance, we compared the performance of ArrayFire and CUDA on the new GTX 1080.\r\n</p>\r\n\r\n<p>\r\nTo do this we built ArrayFire 3.4.0 using the CUDA 8 RC and compared its performance with that of the example provided in <a href=\"http://docs.nvidia.com/cuda/cuda-samples/#black-scholes-option-pricing\">CUDA Samples</a>.\r\n</p>\r\n\r\n\r\nThe results of this benchmark can be seen below.\r\n\r\n<iframe width=\"655.1414131325375\" height=\"323.5\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=256763192&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nThe results indicate ArrayFire v3.4 performs identical to the native kernel at larger simulation sizes, but there is a constant overhead causing issues at smaller sizes. This is one of the issues we want to address in future releases.\r\n</p>\r\n\r\n<p>\r\nNote: The <code>black_scholes</code> function had to be changed slightly as shown below to be similar to the sample provided by CUDA.\r\n</p>\r\n</div>\r\n</div>\r\n\r\n<div id=\"outline-container-sec-3\" class=\"outline-2\">\r\n<h3 id=\"sec-3\">Conclusion</h3>\r\n<div class=\"outline-text-2\" id=\"text-3\">\r\n<p>\r\nThe new improvements to the JIT engine in ArrayFire can seamlessly generate kernels that perform close to handwritten native kernels on GPUs. There is still scope for improvements at smaller sizes. To see what lies ahead for our Just-In-Time compiler, please check out <a href=\"https://github.com/arrayfire/arrayfire/issues/1401\">this github issue</a>.\r\n</p>\r\n</div>\r\n</div>\r\n</div>\r\n','Performance improvements to JIT in ArrayFire 3.4','','inherit','closed','closed','','9252-revision-v1','','','2016-09-19 22:51:23','2016-09-20 02:51:23','',9252,'http://sandbox.arrayfire.com/9252-revision-v1/',0,'revision','',0),(9259,17728,'2016-09-19 22:53:14','2016-09-20 02:53:14','<p>\r\nArrayFire uses <a href=\"http://sandbox.arrayfire.com/performance-of-arrayfire-jit-code-generation/\">Just In Time</a> compilation to combine many light weight functions into a single kernel launch. This along with our <a href=\"http://arrayfire.org/docs/group__arrayfire__func.htm\">easy-to-use API</a> allows users to not only quickly prototype their algorithms, but also get the best out of the underlying hardware.\r\n</p>\r\n\r\n<p>\r\nThis feature has been a favorite among our users in the domains of finance and scientific simulation.\r\n</p>\r\n\r\n<p>\r\nThat said, ArrayFire v3.3 and earlier had a few limitations. Namely:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Multiple outputs with inter-dependent variables were generating multiple kernels.\r\n</li>\r\n<li>The number of operations per kernel was fairly limited by default.\r\n</li>\r\n</ul>\r\n\r\n<p>\r\nIn the latest release of ArrayFire, we addressed these issues to get some pretty impressive numbers.\r\n</p>\r\n\r\n<p>\r\nIn the rest of the post, we demonstrate the performance improvements using our <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/financial/black_scholes_options.cpp\">BlackScholes example</a>. For this particular example, the improvements for the CUDA backend were <b>~8x</b> and OpenCL backend were between <b>~5x</b>.\r\n</p>\r\n\r\n<div id=\"outline-container-sec-1\" class=\"outline-2\">\r\n<h3 id=\"sec-1\">Performance Comparison to v3.3</h3>\r\n<div class=\"outline-text-2\" id=\"text-1\">\r\n<p>\r\n<a href=\"https://en.wikipedia.org/wiki/Black%25E2%2580%2593Scholes_model\">BlackScholes</a> is a commonly used mathematical model in financial markets.\r\n</p>\r\n\r\n<p>\r\nIt takes the following 5 inputs and generates 2 outputs.\r\n</p>\r\n\r\n<p>\r\nThe code to implement this model in arrayfire can be seen below.\r\n</p>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">array cnd(array x)\r\n{\r\n    // constants\r\n    const float a1 =  0.254829592;\r\n    const float a2 = -0.284496736;\r\n    const float a3 =  1.421413741;\r\n    const float a4 = -1.453152027;\r\n    const float a5 =  1.061405429;\r\n    const float p  =  0.3275911;\r\n    const float sqrt2 = sqrt(2.0);\r\n\r\n    // Save the sign of x\r\n    array xSign = sign(x);\r\n\r\n    x = abs(x) / sqrt2;\r\n\r\n    // A&amp;S formula 7.1.26\r\n    array t = 1.0f / (1.0f + p*x);\r\n    array y = 1.0f + 0.5f * (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);\r\n\r\n    return xSign * y + !xSign * (1 - y); // equivalent of (x &gt;= 0) ? y : (1 - y);\r\n}\r\n\r\nstatic void black_scholes(array&amp; C, array&amp; P,\r\n                          const array&amp; S, const array&amp; X,\r\n                          const array&amp; R, const array&amp; V,\r\n                          const array&amp; T)\r\n{\r\n    // Inputs:\r\n    // S: Stock price\r\n    // X: Strike price\r\n    // R: Risk free rate of interest\r\n    // V: Volatility\r\n    // T: Time to maturity\r\n\r\n    // Outputs:\r\n    // C: Call option\r\n    // P: Put option\r\n\r\n    array d1 = log(S / X);\r\n    d1 = d1 + (R + (V*V)*0.5) * T;\r\n    d1 = d1 / (V*sqrt(T));\r\n\r\n    array d2 = d1 - (V*sqrt(T));\r\n\r\n    array cnd_d1 = cnd(d1);\r\n    array cnd_d2 = cnd(d2);\r\n\r\n    C = S * cnd_d1  - (X * exp((-R)*T) * cnd_d2);\r\n    P = X * exp((-R)*T) * (1 - cnd_d2) - (S * (1 - cnd_d1));\r\n}\r\n</pre>\r\n</div>\r\n\r\n<p>\r\nThe <code>black_scholes</code> function contains a long chain of operations and generates two outputs. In older versions of ArrayFire, the Just-In-Time compiler of arrayfire was splitting up this single function call to multiple kernels.\r\n</p>\r\n\r\n<p>\r\nWe solved this in the latest release by:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Enabling <code>af::eval</code> to hint ArrayFire\'s JIT compiler to combine inputs.\r\n</li>\r\n<li>Changing the heuristics to increase the number of operations per kernel.\r\n</li>\r\n</ul>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">black_scholes(C, P, S, X, R, V, T);\r\neval(C, P); // Only change required for v3.4\r\n</pre>\r\n</div>\r\n\r\n\r\n\r\nThese changes resulted in dramatic performance improvements seen below. The following graph compares the number of call and put options being calculated per second on v3.3 and v3.4.\r\n\r\n<br>\r\n\r\n<iframe width=\"650\" height=\"400\" seamless frameborder=\"0\" scrolling=\"no\"\r\nsrc=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=927257953&amp;format=interactive\">\r\n</iframe>\r\n\r\n<br>\r\n\r\nAs we can see, the performance has improved significantly. The absolute time taken when to calculate 2 million options is show below.\r\n\r\n<br>\r\n<br>\r\n\r\n<iframe width=\"513.5\" height=\"104.0141666666666\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=1295781261&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nNote:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>The additional gains made by CUDA are because of a <a href=\"https://github.com/arrayfire/arrayfire/pull/1534\">separate issue</a> involving CUDA JIT that was fixed.\r\n</li>\r\n<li>Only 24 threads of the 32 available were used for the Xeon CPU.\r\n</li>\r\n</ul>\r\n</div>\r\n</div>\r\n\r\n<div id=\"outline-container-sec-2\" class=\"outline-2\">\r\n<h3 id=\"sec-2\">Performance Comparison to Native CUDA</h3>\r\n<div class=\"outline-text-2\" id=\"text-2\">\r\n<p>\r\nTo see how close we can get to the peak performance, we compared the performance of ArrayFire and CUDA on the new GTX 1080.\r\n</p>\r\n\r\n<p>\r\nTo do this we built ArrayFire 3.4.0 using the CUDA 8 RC and compared its performance with that of the example provided in <a href=\"http://docs.nvidia.com/cuda/cuda-samples/#black-scholes-option-pricing\">CUDA Samples</a>.\r\n</p>\r\n\r\n\r\nThe results of this benchmark can be seen below.\r\n\r\n<iframe width=\"655.1414131325375\" height=\"323.5\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=256763192&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nThe results indicate ArrayFire v3.4 performs identical to the native kernel at larger simulation sizes, but there is a constant overhead causing issues at smaller sizes. This is one of the issues we want to address in future releases.\r\n</p>\r\n\r\n<p>\r\nNote: The <code>black_scholes</code> function had to be changed slightly as shown below to be similar to the sample provided by CUDA.\r\n</p>\r\n</div>\r\n</div>\r\n\r\n<div id=\"outline-container-sec-3\" class=\"outline-2\">\r\n<h3 id=\"sec-3\">Conclusion</h3>\r\n<div class=\"outline-text-2\" id=\"text-3\">\r\n<p>\r\nThe new improvements to the JIT engine in ArrayFire can seamlessly generate kernels that perform close to handwritten native kernels on GPUs. There is still scope for improvements at smaller sizes. To see what lies ahead for our Just-In-Time compiler, please check out <a href=\"https://github.com/arrayfire/arrayfire/issues/1401\">this github issue</a>.\r\n</p>\r\n</div>\r\n</div>\r\n</div>\r\n','Performance improvements to JIT in ArrayFire 3.4','','inherit','closed','closed','','9252-revision-v1','','','2016-09-19 22:53:14','2016-09-20 02:53:14','',9252,'http://sandbox.arrayfire.com/9252-revision-v1/',0,'revision','',0),(9260,18673,'2016-09-19 23:34:02','2016-09-20 03:34:02','','rot_quality','Image rotation with different interpolation methods.','inherit','open','closed','','rot_quality','','','2016-09-19 23:34:49','2016-09-20 03:34:49','',9166,'http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png',0,'attachment','image/png',0),(9261,18673,'2016-09-19 23:35:07','2016-09-20 03:35:07','','scale','3x image scaling with different interpolation methods.','inherit','open','closed','','scale','','','2016-09-19 23:35:21','2016-09-20 03:35:21','',9166,'http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale.png',0,'attachment','image/png',0),(9262,17729,'2016-09-19 23:44:48','2016-09-20 03:44:48','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>An example of how to render your data as a vector field has been provided in our examples which you can find <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart renderables</h6>\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 23:44:48','2016-09-20 03:44:48','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9263,17729,'2016-09-19 23:53:36','2016-09-20 03:53:36','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. We have provided an example along with ArrayFire to show case how to render your data as vector fields. You can obtain the complete example code by installing ArrayFire or cloning our project\'s github repository. You can also refer to this example online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart renderables</h6>\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 23:53:36','2016-09-20 03:53:36','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9264,17729,'2016-09-19 23:56:30','2016-09-20 03:56:30','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. We have provided an example along with ArrayFire to show case how to render your data as vector fields. You can obtain the complete example code by installing ArrayFire or cloning our project\'s github repository. You can also refer to the example\'s code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart renderables</h6>\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 23:56:30','2016-09-20 03:56:30','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9265,17729,'2016-09-19 23:57:47','2016-09-20 03:57:47','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. We have provided an example along with ArrayFire to show case how to render your data as vector fields. You can obtain the complete example code by installing ArrayFire or cloning our project\'s github repository. You can also refer to the example\'s code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example renders a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart renderables</h6>\r\n<p>Apart from the above new renderables, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-19 23:57:47','2016-09-20 03:57:47','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9266,17729,'2016-09-20 00:02:58','2016-09-20 04:02:58','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. We have provided an example along with ArrayFire to show case how to render your data as vector fields. You can obtain the complete example code by installing ArrayFire or cloning our project\'s github repository. You can also refer to the example\'s code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example renders a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart graphs</h6>\r\n<p>Prior to v3.4 each chart graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, every window/view supports overlay of different chart graphs now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:02:58','2016-09-20 04:02:58','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9267,17729,'2016-09-20 00:04:01','2016-09-20 04:04:01','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. We have provided an example along with ArrayFire to show case how to render your data as vector fields. You can refer to the example\'s code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example renders a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart graphs</h6>\r\n<p>Prior to v3.4 each chart graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, every window/view supports overlay of different chart graphs now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:04:01','2016-09-20 04:04:01','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9268,17729,'2016-09-20 00:05:38','2016-09-20 04:05:38','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. An example has been added to the ArrayFire\'s suite of examples to show case this new capability of rendering vector fields. You can refer to the example\'s source code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. This example renders a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart graphs</h6>\r\n<p>Prior to v3.4 each chart graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, every window/view supports overlay of different chart graphs now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:05:38','2016-09-20 04:05:38','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9269,18607,'2016-09-21 22:14:10','2016-09-22 02:14:10','<span style=\"font-weight: 400;\">Pseudorandom number generators (PRNGs) are an integral part of many applications in statistics, modeling, and simulations. In ArrayFire v3.4, we introduce random number generation enhancements that improve speed, accuracy, storage, and unity among the ArrayFire backends.</span>\r\n\r\n<span style=\"font-weight: 400;\">Previously in ArrayFire v3.3, each ArrayFire backend used a different PRNG. In ArrayFire v3.4, each ArrayFire backend is able to select from among 3 different random number generators.</span>\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td colspan=\"2\">ArrayFire v3.3 (platform specific)</td>\r\n<td rowspan=\"4\"></td>\r\n<td colspan=\"2\">ArrayFire v3.4 (all generators on all platforms)</td>\r\n</tr>\r\n<tr>\r\n<td>CUDA</td>\r\n<td>XORWOW</td>\r\n<td rowspan=\"3\">CUDA,\r\nOpenCL,\r\nCPU</td>\r\n<td rowspan=\"3\">Philox (CBRNG),\r\nThreefry (CBRNG),\r\nMersenne Twister</td>\r\n</tr>\r\n<tr>\r\n<td>OpenCL</td>\r\n<td>Threefry (CBRNG)</td>\r\n</tr>\r\n<tr>\r\n<td>CPU</td>\r\n<td>Mersenne Twister</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<span style=\"font-weight: 400;\">As seen above, the XORWOW generator (which was only available for CUDA devices previously) has been replaced by the Philox generator which is available along with Threefry and Mersenne Twister on all ArrayFire supported devices. Philox and Threefry are</span><span style=\"font-weight: 400;\"> <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a> (CBRNGs). CBRNGs have two major advantages over traditional PRNGs:</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance - CBRNGs pass rigorous and extensive statistical tests while Mersenne Twister and XORWOW are not as accurate.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space - The amount of storage space required to maintain the state of CBRNGs is minimal compared to Mersenne Twister.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">For these reasons, ArrayFire v3.4 now includes both the Philox and Threefry CBRNGs. Mersenne Twister will continue to be maintained due to its ubiquity in technical computing.</span>\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Usage[/custom_headline]\r\n<span style=\"font-weight: 400;\">Users create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed. Then the objects are passed into the <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> functions which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine. These default random engines contain the state of the engine and can be reset or changed by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\n//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nThe default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> because it has the best statistical properties among the available generators. For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Performance Results[/custom_headline]\r\n\r\n[caption id=\"attachment_9312\" align=\"aligncenter\" width=\"600\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\"><img class=\"wp-image-9312 size-full\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\" alt=\"OpenCL Backend Performance\" width=\"600\" height=\"371\" /></a> OpenCL Backend Performance[/caption]\r\n\r\n[caption id=\"attachment_9313\" align=\"aligncenter\" width=\"600\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\"><img class=\"wp-image-9313 size-full\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\" alt=\"CUDA Backend Performance\" width=\"600\" height=\"371\" /></a> CUDA Backend Performance[/caption]\r\n\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Future Plans[/custom_headline]\r\n\r\nFuture releases of ArrayFire will include the XORWOW and MRG32K3a generators for all platforms.\r\n\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Download[/custom_headline]\r\n\r\nArrayFire v3.4 can be downloaded from these locations:\r\n<ul>\r\n 	<li><a href=\"http://sandbox.arrayfire.com/download/\">Binaries</a></li>\r\n 	<li><a href=\"https://github.com/arrayfire\">Source code</a></li>\r\n</ul>\r\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Community[/custom_headline]\r\n\r\nArrayFire is continually improving through the addition of new random number generators and statistical functions. We welcome your feedback:\r\n<ul>\r\n 	<li>General discussion forums on the <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">ArrayFire Google Group</a></li>\r\n 	<li>Live discussion chat on the <a href=\"https://gitter.im/arrayfire/arrayfire?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\">ArrayFire Gitter</a></li>\r\n 	<li>Issue reports on the <a href=\"https://github.com/arrayfire/arrayfire/issues\">ArrayFire GitHub</a></li>\r\n</ul>\r\nFinally, as you find success with ArrayFire, we invite you to contribute a post to this blog to share with the broader community. Email <a href=\"mailto:scott@arrayfire.com\">scott@arrayfire.com</a> to contribute to this blog.','Random Number Generators in ArrayFire v3.4','','publish','open','closed','','random-number-generators-in-arrayfire-v3-4','','','2016-09-21 22:14:10','2016-09-22 02:14:10','',0,'http://sandbox.arrayfire.com/?p=9269',0,'post','',0),(9270,17728,'2016-09-20 00:06:54','2016-09-20 04:06:54','<p>\r\nArrayFire uses <a href=\"http://sandbox.arrayfire.com/performance-of-arrayfire-jit-code-generation/\">Just In Time</a> compilation to combine many light weight functions into a single kernel launch. This along with our <a href=\"http://arrayfire.org/docs/group__arrayfire__func.htm\">easy-to-use API</a> allows users to not only quickly prototype their algorithms, but also get the best out of the underlying hardware.\r\n</p>\r\n\r\n<p>\r\nThis feature has been a favorite among our users in the domains of finance and scientific simulation.\r\n</p>\r\n\r\n<p>\r\nThat said, ArrayFire v3.3 and earlier had a few limitations. Namely:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Multiple outputs with inter-dependent variables were generating multiple kernels.\r\n</li>\r\n<li>The number of operations per kernel was fairly limited by default.\r\n</li>\r\n</ul>\r\n\r\n<p>\r\nIn the latest release of ArrayFire, we addressed these issues to get some pretty impressive numbers.\r\n</p>\r\n\r\n<p>\r\nIn the rest of the post, we demonstrate the performance improvements using our <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/financial/black_scholes_options.cpp\">BlackScholes example</a>. For this particular example, the improvements for the CUDA backend were <b>~8x</b> and OpenCL backend were between <b>~5x</b>.\r\n</p>\r\n\r\n<div id=\"outline-container-sec-1\" class=\"outline-2\">\r\n<h3 id=\"sec-1\">Performance Comparison to v3.3</h3>\r\n<div class=\"outline-text-2\" id=\"text-1\">\r\n<p>\r\n<a href=\"https://en.wikipedia.org/wiki/Black%25E2%2580%2593Scholes_model\">BlackScholes</a> is a commonly used mathematical model in financial markets.\r\n</p>\r\n\r\n<p>\r\nIt takes the following 5 inputs and generates 2 outputs.\r\n</p>\r\n\r\n<p>\r\nThe code to implement this model in arrayfire can be seen below.\r\n</p>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">array cnd(array x)\r\n{\r\n    // constants\r\n    const float a1 =  0.254829592;\r\n    const float a2 = -0.284496736;\r\n    const float a3 =  1.421413741;\r\n    const float a4 = -1.453152027;\r\n    const float a5 =  1.061405429;\r\n    const float p  =  0.3275911;\r\n    const float sqrt2 = sqrt(2.0);\r\n\r\n    // Save the sign of x\r\n    array xSign = sign(x);\r\n\r\n    x = abs(x) / sqrt2;\r\n\r\n    // A&amp;S formula 7.1.26\r\n    array t = 1.0f / (1.0f + p*x);\r\n    array y = 1.0f + 0.5f * (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);\r\n\r\n    return xSign * y + !xSign * (1 - y); // equivalent of (x &gt;= 0) ? y : (1 - y);\r\n}\r\n\r\nstatic void black_scholes(array&amp; C, array&amp; P,\r\n                          const array&amp; S, const array&amp; X,\r\n                          const array&amp; R, const array&amp; V,\r\n                          const array&amp; T)\r\n{\r\n    // Inputs:\r\n    // S: Stock price\r\n    // X: Strike price\r\n    // R: Risk free rate of interest\r\n    // V: Volatility\r\n    // T: Time to maturity\r\n\r\n    // Outputs:\r\n    // C: Call option\r\n    // P: Put option\r\n\r\n    array d1 = log(S / X);\r\n    d1 = d1 + (R + (V*V)*0.5) * T;\r\n    d1 = d1 / (V*sqrt(T));\r\n\r\n    array d2 = d1 - (V*sqrt(T));\r\n\r\n    array cnd_d1 = cnd(d1);\r\n    array cnd_d2 = cnd(d2);\r\n\r\n    C = S * cnd_d1  - (X * exp((-R)*T) * cnd_d2);\r\n    P = X * exp((-R)*T) * (1 - cnd_d2) - (S * (1 - cnd_d1));\r\n}\r\n</pre>\r\n</div>\r\n\r\n<p>\r\nThe <code>black_scholes</code> function contains a long chain of operations and generates two outputs. In older versions of ArrayFire, the Just-In-Time compiler of arrayfire was splitting up this single function call to multiple kernels.\r\n</p>\r\n\r\n<p>\r\nWe solved this in the latest release by:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>Enabling <code>af::eval</code> to hint ArrayFire\'s JIT compiler to combine inputs.\r\n</li>\r\n<li>Changing the heuristics to increase the number of operations per kernel.\r\n</li>\r\n</ul>\r\n\r\n<div class=\"org-src-container\">\r\n\r\n<pre class=\"src src-C++\">black_scholes(C, P, S, X, R, V, T);\r\neval(C, P); // Only change required for v3.4\r\n</pre>\r\n</div>\r\n\r\n\r\n\r\nThese changes resulted in dramatic performance improvements seen below. The following graph compares the number of call and put options being calculated per second on v3.3 and v3.4.\r\n\r\n<br>\r\n\r\n<iframe width=\"650\" height=\"400\" seamless frameborder=\"0\" scrolling=\"no\"\r\nsrc=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=927257953&amp;format=interactive\">\r\n</iframe>\r\n\r\n<br>\r\n\r\nAs we can see, the performance has improved significantly. The absolute time taken when to calculate 2 million options is show below.\r\n\r\n<br>\r\n<br>\r\n\r\n<iframe width=\"513.5\" height=\"104.0141666666666\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=1295781261&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nNote:\r\n</p>\r\n<ul class=\"org-ul\">\r\n<li>The additional gains made by CUDA are because of a <a href=\"https://github.com/arrayfire/arrayfire/pull/1534\">separate issue</a> involving CUDA JIT that was fixed.\r\n</li>\r\n<li>Only 24 threads of the 32 available were used for the Xeon CPU.\r\n</li>\r\n</ul>\r\n</div>\r\n</div>\r\n\r\n<div id=\"outline-container-sec-2\" class=\"outline-2\">\r\n<h3 id=\"sec-2\">Performance Comparison to Native CUDA</h3>\r\n<div class=\"outline-text-2\" id=\"text-2\">\r\n<p>\r\nTo see how close we can get to the peak performance, we compared the performance of ArrayFire and CUDA on the new GTX 1080.\r\n</p>\r\n\r\n<p>\r\nTo do this we built ArrayFire 3.4 using the CUDA 8 RC and compared its performance with that of the example provided in <a href=\"http://docs.nvidia.com/cuda/cuda-samples/#black-scholes-option-pricing\">CUDA Samples</a>.\r\n</p>\r\n\r\n\r\nThe results of this benchmark can be seen below.\r\n\r\n<iframe width=\"655.1414131325375\" height=\"323.5\" seamless frameborder=\"0\" scrolling=\"no\" src=\"https://docs.google.com/spreadsheets/d/1o4C5KZ4B5he3Ac8mJ9Z6Z_N-hlATeJwhP-j6XJtbEPA/pubchart?oid=256763192&amp;format=interactive\"></iframe>\r\n\r\n<p>\r\nThe results indicate ArrayFire v3.4 performs identical to the native kernel at larger simulation sizes, but there is a constant overhead causing issues at smaller sizes. This is one of the issues we want to address in future releases.\r\n</p>\r\n\r\n<p>\r\nNote: The <code>black_scholes</code> function had to be changed slightly as shown below to be similar to the sample provided by CUDA.\r\n</p>\r\n</div>\r\n</div>\r\n\r\n<div id=\"outline-container-sec-3\" class=\"outline-2\">\r\n<h3 id=\"sec-3\">Conclusion</h3>\r\n<div class=\"outline-text-2\" id=\"text-3\">\r\n<p>\r\nThe new improvements to the JIT engine in ArrayFire can seamlessly generate kernels that perform close to handwritten native kernels on GPUs. There is still scope for improvements at smaller sizes. To see what lies ahead for our Just-In-Time compiler, please check out <a href=\"https://github.com/arrayfire/arrayfire/issues/1401\">this github issue</a>.\r\n</p>\r\n</div>\r\n</div>\r\n</div>\r\n','Performance improvements to JIT in ArrayFire 3.4','','inherit','closed','closed','','9252-revision-v1','','','2016-09-20 00:06:54','2016-09-20 04:06:54','',9252,'http://sandbox.arrayfire.com/9252-revision-v1/',0,'revision','',0),(9271,17729,'2016-09-20 00:06:56','2016-09-20 04:06:56','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. An example has been added to the ArrayFire\'s suite of examples to show case this new capability of rendering vector fields. You can refer to the example\'s source code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. A screenshot of this example\'s render with a static and dynamic vector field in multi-view mode is shown below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart graphs</h6>\r\n<p>Prior to v3.4 each chart graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, every window/view supports overlay of different chart graphs now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:06:56','2016-09-20 04:06:56','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9272,18607,'2016-09-20 00:07:13','2016-09-20 04:07:13','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. Arrayfire, therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the Counter Based Random Number Generators. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, users now have the ability to select between these PRNGs :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Philox (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Threefry (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. A random number generator can be initialized by specifying the random engine type and </span>','','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:07:13','2016-09-20 04:07:13','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9273,17729,'2016-09-20 00:07:33','2016-09-20 04:07:33','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. An example has been added to the ArrayFire\'s suite of examples to show case this new capability of rendering vector fields. You can refer to the example\'s source code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. A screenshot of this example that render\'s a static and dynamic vector field in multi-view mode is shown below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for chart graphs</h6>\r\n<p>Prior to v3.4 each chart graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, every window/view supports overlay of different chart graphs now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:07:33','2016-09-20 04:07:33','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9274,18673,'2016-09-20 00:07:54','2016-09-20 04:07:54','There are a number of  additions and updates to image based features in the new 3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods are:\r\n<ul>\r\n 	<li>AF_INTERP_LINEAR_COSINE</li>\r\n 	<li>AF_INTERP_CUBIC</li>\r\n</ul>\r\nfor 1-d functions and:\r\n<ul>\r\n 	<li>AF_INTERP_BILINEAR_COSINE</li>\r\n 	<li>AF_INTERP_BICUBIC</li>\r\n</ul>\r\nfor 2-d functions. The behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> Starting from raw data, linear interpolation, linear-cosine interpolation, to cubic interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can re-sample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolants further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\nDifferent interpolants greatly affect the final result of the image processing operations. In general, the bilinear and bilinear cosine interpolants produce a good result when up-scaling an image, however they end up with a somewhat blurry look. The bicubic method method ends up with slightly stronger borders and ends up pleasantly sharpening the image. Below are some examples with rotation and scaling.\r\n\r\n[caption id=\"attachment_9260\" align=\"aligncenter\" width=\"742\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png\"><img class=\"wp-image-9260 size-large\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality-1024x405.png\" alt=\"Image rotation with different interpolation methods.\" width=\"742\" height=\"293\" /></a> Image rotation with different interpolation methods.[/caption]\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9261\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale.png\"><img class=\"size-medium wp-image-9261\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale-300x276.png\" alt=\"3x image scaling with different interpolation methods.\" width=\"300\" height=\"276\" /></a> 3x image scaling with different interpolation methods.[/caption]\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nAnother addition to this release of ArrayFire are image moments. Image moments are weighted averages of pixels in an image which let us find out some useful properties of an image. A common use of image moments is to find the center of mass or area of some image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\nArrayFire is always adding new methods to help you with accelerating your applications. We hope the new functions will be the vital tools that assist and inspire in your high performance applications!','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-20 00:07:54','2016-09-20 04:07:54','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9275,18607,'2016-09-20 00:09:38','2016-09-20 04:09:38','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. Arrayfire, therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the Counter Based Random Number Generators. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, users now have the ability to select between these PRNGs :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Philox (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Threefry (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n\r\n<span class=\"lang:default decode:true  crayon-inline \">unsigned seed; af::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed); af::randomEngine rt(AF_RANDOM_ENGINE_THREEFRY, seed); af::randomEngine rm(AF_RANDOM_ENGINE_MERSENNE, seed);</span>','','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:09:38','2016-09-20 04:09:38','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9276,17729,'2016-09-20 00:10:11','2016-09-20 04:10:11','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. An example has been added to the ArrayFire\'s suite of examples to show case this new capability of rendering vector fields. You can refer to the example\'s source code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. A screenshot of this example that render\'s a static and dynamic vector field in multi-view mode is shown below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for graphs</h6>\r\n<p>Prior to v3.4 each graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, and from now on every window/view supports overlay of graphs. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, two dimensional line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. \r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\nHere you go, enjoy the gifs! You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:10:11','2016-09-20 04:10:11','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9277,18607,'2016-09-20 00:12:48','2016-09-20 04:12:48','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. Arrayfire, therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the Counter Based Random Number Generators. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, users now have the ability to select between these PRNGs :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Philox (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Threefry (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::randomEngine rt(AF_RANDOM_ENGINE_THREEFRY, seed);\r\naf::randomEngine rm(AF_RANDOM_ENGINE_MERSENNE, seed);</pre>\r\n&nbsp;','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:12:48','2016-09-20 04:12:48','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9278,18673,'2016-09-20 00:12:54','2016-09-20 04:12:54','There are a number of  additions and updates to image based features in the new 3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods are:\r\n<ul>\r\n 	<li>AF_INTERP_LINEAR_COSINE</li>\r\n 	<li>AF_INTERP_CUBIC</li>\r\n</ul>\r\nfor 1-d functions and:\r\n<ul>\r\n 	<li>AF_INTERP_BILINEAR_COSINE</li>\r\n 	<li>AF_INTERP_BICUBIC</li>\r\n</ul>\r\nfor 2-d functions. The behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> Starting from raw data, linear interpolation, linear-cosine interpolation, to cubic interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can re-sample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolants further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\nDifferent interpolants greatly affect the final result of the image processing operations. In general, the bilinear and bilinear cosine interpolants produce a good result when up-scaling an image, however they end up with a somewhat blurry look. The bicubic method method ends up with slightly stronger borders and ends up pleasantly sharpening the image. Below are some examples with rotation.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9260\" align=\"aligncenter\" width=\"742\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png\"><img class=\"wp-image-9260 size-large\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality-1024x405.png\" alt=\"Image rotation with different interpolation methods.\" width=\"742\" height=\"293\" /></a> Image rotation with different interpolation methods.[/caption]\r\n\r\n&nbsp;\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nAnother addition to this release of ArrayFire are image moments. Image moments are weighted averages of pixels in an image which let us find out some useful properties of an image. A common use of image moments is to find the center of mass or area of some image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\nArrayFire is always adding new methods to help you with accelerating your applications. We hope the new functions will be the vital tools that assist and inspire in your high performance applications!','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-20 00:12:54','2016-09-20 04:12:54','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9279,18673,'2016-09-20 00:13:54','2016-09-20 04:13:54','There are a number of  additions and updates to image based features in the new 3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods are:\r\n<ul>\r\n 	<li>AF_INTERP_LINEAR_COSINE</li>\r\n 	<li>AF_INTERP_CUBIC</li>\r\n</ul>\r\nfor 1-d functions and:\r\n<ul>\r\n 	<li>AF_INTERP_BILINEAR_COSINE</li>\r\n 	<li>AF_INTERP_BICUBIC</li>\r\n</ul>\r\nfor 2-d functions. The behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> Starting from raw data, linear interpolation, linear-cosine interpolation, to cubic interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can re-sample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolants further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\nDifferent interpolants greatly affect the final result of the image processing operations. In general, the bilinear and bilinear cosine interpolants produce a good result when up-scaling an image, however they end up with a somewhat blurry look. The bicubic method method ends up with slightly stronger borders and ends up pleasantly sharpening the image. Below are some examples with rotation.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9260\" align=\"aligncenter\" width=\"742\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png\"><img class=\"wp-image-9260 size-large\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality-1024x405.png\" alt=\"Image rotation with different interpolation methods.\" width=\"742\" height=\"293\" /></a> Image rotation with different interpolation methods. Left to right: nearest neighbor, bilinear, bilinear cosine, cubic[/caption]\r\n\r\n&nbsp;\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nAnother addition to this release of ArrayFire are image moments. Image moments are weighted averages of pixels in an image which let us find out some useful properties of an image. A common use of image moments is to find the center of mass or area of some image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\nArrayFire is always adding new methods to help you with accelerating your applications. We hope the new functions will be the vital tools that assist and inspire in your high performance applications!','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-20 00:13:54','2016-09-20 04:13:54','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9280,18673,'2016-09-20 00:15:47','2016-09-20 04:15:47','There are a number of  additions and updates to image based features in the new 3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_LINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_CUBIC</strong></li>\r\n</ul>\r\nfor 1-d functions and:\r\n<ul>\r\n 	<li><strong>AF_INTERP_BILINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_BICUBIC</strong></li>\r\n</ul>\r\nfor 2-d functions. The behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> Starting from raw data, linear interpolation, linear-cosine interpolation, to cubic interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can re-sample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolants further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\nDifferent interpolants greatly affect the final result of the image processing operations. In general, the bilinear and bilinear cosine interpolants produce a good result when up-scaling an image, however they end up with a somewhat blurry look. The bicubic method method ends up with slightly stronger borders and ends up pleasantly sharpening the image. Below are some examples with rotation.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9260\" align=\"aligncenter\" width=\"742\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png\"><img class=\"wp-image-9260 size-large\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality-1024x405.png\" alt=\"Image rotation with different interpolation methods.\" width=\"742\" height=\"293\" /></a> Image rotation with different interpolation methods. Left to right: nearest neighbor, bilinear, bilinear cosine, cubic[/caption]\r\n\r\n&nbsp;\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nAnother addition to this release of ArrayFire are image moments. Image moments are weighted averages of pixels in an image which let us find out some useful properties of an image. A common use of image moments is to find the center of mass or area of some image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\nArrayFire is always adding new methods to help you with accelerating your applications. We hope the new functions will be the vital tools that assist and inspire in your high performance applications!','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-20 00:15:47','2016-09-20 04:15:47','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9281,18607,'2016-09-20 00:15:52','2016-09-20 04:15:52','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. Arrayfire, therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the Counter Based Random Number Generators. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, users now have the ability to select between these PRNGs :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Philox (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Threefry (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. The method to generate a sequence of random numbers is slightly altered. <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  can accept an additional parameter for the random number generator. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf:array R = af::randu(elem, f32, rp);</pre>\r\n&nbsp;','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:15:52','2016-09-20 04:15:52','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9282,17729,'2016-09-20 00:16:24','2016-09-20 04:16:24','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. An example has been added to the ArrayFire\'s suite of examples to show case this new capability of rendering vector fields. You can refer to the example\'s source code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. A screenshot of this example that render\'s a static and dynamic vector field in multi-view mode is shown below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for graphs</h6>\r\n<p>Prior to v3.4 each graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, and from now on every window/view supports overlay of graphs. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, two dimensional line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nWhile taking screen shots for the images for new rendering functions, i found the gifs for our simple yet fun to watch examples - conway, gravity simulation and julia fractal. You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot.\r\n\r\n<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library via <a href=\"https://github.com/arrayfire/arrayfire/issues\" target=\"_blank\">github issues</a>. We have a <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\" target=\"_blank\">google groups forum</a> where you can post your questions as well.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:16:24','2016-09-20 04:16:24','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9283,18673,'2016-09-20 00:18:59','2016-09-20 04:18:59','There are a number of  additions and updates to image based features in the new 3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_LINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_CUBIC</strong></li>\r\n</ul>\r\nfor 1-d functions and:\r\n<ul>\r\n 	<li><strong>AF_INTERP_BILINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_BICUBIC</strong></li>\r\n</ul>\r\nfor 2-d functions. The behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> Starting from raw data, linear interpolation, linear-cosine interpolation, to cubic interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can re-sample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolants further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\nDifferent interpolants greatly affect the final result of the image processing operations. In general, the bilinear and bilinear cosine interpolants produce a good result when up-scaling an image, however they end up with a somewhat blurry look. The bicubic method method ends up with slightly stronger borders and ends up pleasantly sharpening the image. Below are some examples with rotation.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9260\" align=\"alignleft\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png\"><img class=\"wp-image-9260 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality-300x119.png\" alt=\"Image rotation with different interpolation methods.\" width=\"300\" height=\"119\" /></a> Image rotation with different interpolation methods. Left to right: nearest neighbor, bilinear, bilinear cosine, cubic[/caption]\r\n\r\n[caption id=\"attachment_9261\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale.png\"><img class=\"size-medium wp-image-9261\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale-300x276.png\" alt=\"3x image scaling with different interpolation methods.\" width=\"300\" height=\"276\" /></a> 3x image scaling with different sampling methods. Top to bottom: nearest neighbor, bilinear cosine, bicubic[/caption]\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nAnother addition to this release of ArrayFire are image moments. Image moments are weighted averages of pixels in an image which let us find out some useful properties of an image. A common use of image moments is to find the center of mass or area of some image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\nArrayFire is always adding new methods to help you with accelerating your applications. We hope the new functions will be the vital tools that assist and inspire in your high performance applications!','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-20 00:18:59','2016-09-20 04:18:59','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9284,18673,'2016-09-20 00:19:42','2016-09-20 04:19:42','There are a number of  additions and updates to image based features in the new 3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_LINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_CUBIC</strong></li>\r\n</ul>\r\nfor 1-d functions and:\r\n<ul>\r\n 	<li><strong>AF_INTERP_BILINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_BICUBIC</strong></li>\r\n</ul>\r\nfor 2-d functions. The behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> Starting from raw data, linear interpolation, linear-cosine interpolation, to cubic interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can re-sample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolants further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\nDifferent interpolants greatly affect the final result of the image processing operations. In general, the bilinear and bilinear cosine interpolants produce a good result when up-scaling an image, however they end up with a somewhat blurry look. The bicubic method method ends up with slightly stronger borders and ends up pleasantly sharpening the image. Below are some examples with rotation.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9260\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png\"><img class=\"wp-image-9260 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality-300x119.png\" alt=\"Image rotation with different interpolation methods.\" width=\"300\" height=\"119\" /></a> Image rotation with different interpolation methods. Left to right: nearest neighbor, bilinear, bilinear cosine, cubic[/caption]\r\n\r\n[caption id=\"attachment_9261\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale.png\"><img class=\"size-medium wp-image-9261\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale-300x276.png\" alt=\"3x image scaling with different interpolation methods.\" width=\"300\" height=\"276\" /></a> 3x image scaling with different sampling methods. Top to bottom: nearest neighbor, bilinear cosine, bicubic[/caption]\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nAnother addition to this release of ArrayFire are image moments. Image moments are weighted averages of pixels in an image which let us find out some useful properties of an image. A common use of image moments is to find the center of mass or area of some image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\nArrayFire is always adding new methods to help you with accelerating your applications. We hope the new functions will be the vital tools that assist and inspire in your high performance applications!','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-20 00:19:42','2016-09-20 04:19:42','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9285,18673,'2016-09-20 00:20:52','2016-09-20 04:20:52','There are a number of  additions and updates to image based features in the new 3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_LINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_CUBIC</strong></li>\r\n</ul>\r\nfor 1-d functions and:\r\n<ul>\r\n 	<li><strong>AF_INTERP_BILINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_BICUBIC</strong></li>\r\n</ul>\r\nfor 2-d functions. The behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> Starting from raw data, linear interpolation, linear-cosine interpolation, to cubic interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can re-sample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolants further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\nDifferent interpolants greatly affect the final result of the image processing operations. In general, the bilinear and bilinear cosine interpolants produce a good result when up-scaling an image, however they end up with a somewhat blurry look. The bicubic method method ends up with slightly stronger borders and ends up pleasantly sharpening the image. Below are some examples with rotation and scaling.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9260\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png\"><img class=\"wp-image-9260 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality-300x119.png\" alt=\"Image rotation with different interpolation methods.\" width=\"300\" height=\"119\" /></a> Image rotation with different interpolation methods. Left to right: nearest neighbor, bilinear, bilinear cosine, cubic[/caption]\r\n\r\n[caption id=\"attachment_9261\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale.png\"><img class=\"size-medium wp-image-9261\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale-300x276.png\" alt=\"3x image scaling with different interpolation methods.\" width=\"300\" height=\"276\" /></a> 3x image scaling with different sampling methods. Top to bottom: nearest neighbor, bilinear cosine, bicubic[/caption]\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nAnother addition to this release of ArrayFire are image moments. Image moments are weighted averages of pixels in an image which let us find out some useful properties of an image. A common use of image moments is to find the center of mass or area of some image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\nArrayFire is always adding new methods to help you with accelerating your applications. We hope the new functions will be the vital tools that assist and inspire in your high performance applications!','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-20 00:20:52','2016-09-20 04:20:52','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9286,18607,'2016-09-20 00:22:30','2016-09-20 04:22:30','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. Arrayfire, therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the Counter Based Random Number Generators. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, users now have the ability to select between these PRNGs :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Philox (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Threefry (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. The method to generate a sequence of random numbers is slightly altered. <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  can accept an additional parameter for the random number generator. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\n&nbsp;','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:22:30','2016-09-20 04:22:30','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9287,18607,'2016-09-20 00:22:58','2016-09-20 04:22:58','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. Arrayfire, therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the Counter Based Random Number Generators. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, users now have the ability to select between these PRNGs :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Philox (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Threefry (CBRNG)</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. The method to generate a sequence of random numbers is slightly altered. The functions <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  can accept an additional parameter for the random number generator. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\n&nbsp;','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:22:58','2016-09-20 04:22:58','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9288,17729,'2016-09-20 00:24:12','2016-09-20 04:24:12','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. An example has been added to the ArrayFire\'s suite of examples to show case this new capability of rendering vector fields. You can refer to the example\'s source code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. A screenshot of this example that render\'s a static and dynamic vector field in multi-view mode is shown below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for graphs</h6>\r\n<p>Prior to v3.4 each graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, and from now on every window/view supports overlay of graphs. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, two dimensional line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following renerables support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nIt is always fun to watch short animations that based off of simple equations. Given below are the animations of our conway, gravity simulation and julia fractal examples, hope you enjoy them as well. You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all functions that rendered graphs used to compute the axes limits pertaining to corresponding data, automatically. This additional step of computing axes is now not performed any more and the user has to set the graph\'s axes limits using the new API that has been provided to do the same.\r\n\r\n<p>Given below is an example showcasing the changes one has to make to their program if they are using any functions that render graphs such as plot, hist, scatter.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library via <a href=\"https://github.com/arrayfire/arrayfire/issues\" target=\"_blank\">github issues</a>. We have a <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\" target=\"_blank\">google groups forum</a> where you can post your questions as well.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:24:12','2016-09-20 04:24:12','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9289,17729,'2016-09-20 00:25:36','2016-09-20 04:25:36','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. An example has been added to the ArrayFire\'s suite of examples to show case this new capability of rendering vector fields. You can refer to the example\'s source code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. A screenshot of this example that render\'s a static and dynamic vector field in multi-view mode is shown below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for graphs</h6>\r\n<p>Prior to v3.4 each graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, and from now on every window/view supports overlay of graphs. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, two dimensional line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following graphs support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nIt is always fun to watch short animations that based off of simple equations. Given below are the animations of our conway, gravity simulation and julia fractal examples, hope you enjoy them as well. You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all functions that rendered graphs used to compute the axes limits pertaining to corresponding data, automatically. This additional step of computing axes is now not performed any more and the user has to set the graph\'s axes limits using the new API that has been provided to do the same.\r\n\r\n<p>Given below is an example showcasing the changes one has to make to their program if they are using any functions that render graphs such as plot, hist, scatter.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library via <a href=\"https://github.com/arrayfire/arrayfire/issues\" target=\"_blank\">github issues</a>. We have a <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\" target=\"_blank\">google groups forum</a> where you can post your questions as well.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:25:36','2016-09-20 04:25:36','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9290,17729,'2016-09-20 00:29:27','2016-09-20 04:29:27','<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Untitled Document.md</title><style></style></head><body id=\"preview\">\r\n<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4 release.</p>\r\n<h4><a id=\"New_Features_56\"></a>New Features</h4>\r\n<h6>Vector Fields</h6>\r\n<p>We have added visualisation support to render ArrayFire <a href=\"http://arrayfire.org/docs/array_8h_source.htm\" target=\"_blank\">array</a> objects as vector fields. An example has been added to the ArrayFire\'s suite of examples to show case this new capability of rendering vector fields. You can refer to the example\'s source code online over <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp\" target=\"_blank\">here</a>. A screenshot of this example that render\'s a static and dynamic vector field in multi-view mode is shown below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png\" alt=\"vfield\" width=\"742\" height=\"399\" class=\"alignnone size-large wp-image-9185\" /></a>\r\n<h6>Overlay support for graphs</h6>\r\n<p>Prior to v3.4 release, each graph such as plot, hist, scatter etc. were rendered one per each view/window. Overlaying one with the other was not supported. This changes with v3.4 release, and from now on every window/view supports overlay of graphs. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.\r\n\r\n<p>Given below is a screen shot of mult-view mode which renders an image, two dimensional line plot, histogram and surface. You can find the corresponding example code <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp\" target=\"_blank\">here</a>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png\" alt=\"swe\" width=\"742\" height=\"398\" class=\"alignnone size-large wp-image-9184\" /></a>\r\n\r\nThe following graphs support overlay if they are of same type of object (2d/3d).</p>\r\n<ul>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot3.cpp\" target=\"_blank\">plot</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-300x300.png\" alt=\"plot3\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9211\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/histogram.cpp\" target=\"_blank\">histogram</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png\" alt=\"histogram\" width=\"300\" height=\"152\" class=\"alignnone size-medium wp-image-9207\" /></a></li>\r\n<li><a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/surface.cpp\" target=\"_blank\">surface</a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png\" alt=\"surface\" width=\"300\" height=\"300\" class=\"alignnone size-medium wp-image-9212\" /></a></li>\r\n<li>vector fields</li>\r\n</ul>\r\n<p>You can see an example screenshot of how overlay of plots looks like below.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png\" alt=\"multipleplot\" width=\"1002\" height=\"828\" class=\"alignnone size-full wp-image-9182\" /></a>\r\n\r\n<h6>Fun Animations</h6>\r\nIt is always fun to watch short animations that based off of simple equations. Given below are the animations of our conway, gravity simulation and julia fractal examples, hope you enjoy them as well. You can find the code for these samples here, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway.cpp\" target=\"_blank\">conway</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/conway_pretty.cpp\" target=\"_blank\">conway_pretty</a>, <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/gravity_sim.cpp\" target=\"_blank\">gravity</a> and <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/fractal.cpp\" target=\"_blank\">julia fractal</a>.\r\n\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway.gif\" alt=\"conway\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9227\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/conway_pretty.gif\" alt=\"conway_pretty\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9228\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/gravity.gif\" alt=\"gravity\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9216\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/julia.gif\" alt=\"julia\" width=\"256\" height=\"256\" class=\"alignnone size-full wp-image-9240\" /></a>\r\n\r\n<h5><a id=\"Behavioral_Changes_13\"></a>Behavioral Changes</h5>\r\n<p>Prior to v3.4 release, all functions that rendered graphs used to compute the axes limits pertaining to corresponding data, automatically. This additional step of computing axes is now not performed any more and the user has to set the graph\'s axes limits using the new API that has been provided to do the same.\r\n\r\n<p>Given below is an example showcasing the changes one has to make to their program if they are using any functions that render graphs such as plot, hist, scatter.</p>\r\n\r\n<pre><code class=\"language-cpp\">\r\naf::Window myWindow(800, 800, \"2D Plot example: ArrayFire\");\r\n\r\narray Y;\r\nint sign = 1;\r\narray X = seq(-af::Pi, af::Pi, PRECISION);\r\narray noise = randn(X.dims(0))/5.f;\r\n\r\nmyWindow.grid(2, 1);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);\r\n// Set the axes limits to view (0,0), prior to v3.4 this was not needed\r\nmyWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);\r\n\r\nfor (double val=0; !myWindow.close(); )\r\n{\r\n    Y = sin(X);\r\n\r\n    myWindow(0,0).plot(X, Y);\r\n    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);\r\n\r\n    myWindow.show();\r\n\r\n    X = X + PRECISION * float(sign);\r\n    val += PRECISION * float(sign);\r\n\r\n    if (val>af::Pi) {\r\n        sign = -1;\r\n    } else if (val<-af::Pi) {\r\n        sign = 1;\r\n    }\r\n}\r\n</code></pre>\r\n<p>Above code should render as the following and you can find the complete example <a href=\"https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp\" target=\"_blank\">here</a>.</p>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png\"><img src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png\" alt=\"plot2d\" width=\"742\" height=\"672\" class=\"alignnone size-large wp-image-9183\" /></a>\r\n\r\n<h5><a id=\"Misc_Changes_74\"></a>Misc Changes</h5>\r\n<p>Removed <a href=\"http://glew.sourceforge.net/\">GLEW</a> and replaced with <a href=\"https://github.com/cginternals/glbinding\">glbinding</a>.</p>\r\n<h5><a id=\"Conclusion_77\"></a>Conclusion</h5>\r\n<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library via <a href=\"https://github.com/arrayfire/arrayfire/issues\" target=\"_blank\">github issues</a>. We have a <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\" target=\"_blank\">google groups forum</a> where you can post your questions as well.</p>\r\n\r\n</body></html>','Graphics updates in ArrayFire v3.4','','inherit','closed','closed','','9172-revision-v1','','','2016-09-20 00:29:27','2016-09-20 04:29:27','',9172,'http://sandbox.arrayfire.com/9172-revision-v1/',0,'revision','',0),(9291,18607,'2016-09-20 00:31:20','2016-09-20 04:31:20','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. Arrayfire, therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the Counter Based Random Number Generators. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between these PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. The method to generate a sequence of random numbers is slightly altered. The functions <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  can accept an additional parameter for the random number generator. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\n<strong>Future Plans</strong>\r\n\r\n&nbsp;','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:31:20','2016-09-20 04:31:20','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9292,18607,'2016-09-20 00:33:49','2016-09-20 04:33:49','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. Arrayfire, therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the Counter Based Random Number Generators. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between these PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. The method to generate a sequence of random numbers is slightly altered. The functions <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  can accept an additional parameter for the random number generator. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\n<h4>Future Plans</h4>\r\n&nbsp;','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:33:49','2016-09-20 04:33:49','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9293,18607,'2016-09-20 00:39:35','2016-09-20 04:39:35','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the Counter Based Random Number Generators. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between these PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. The method to generate a sequence of random numbers is slightly altered. The functions <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  can accept an additional parameter for the random number generator. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true  crayon-inline \">randu</span>  and <span class=\"lang:default decode:true  crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from a variety of random number distributions. We plan to add a number of them:\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:39:35','2016-09-20 04:39:35','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9294,18607,'2016-09-20 00:41:44','2016-09-20 04:41:44','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. In the earlier versions, PRNG algorithms were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between these PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. The method to generate a sequence of random numbers is slightly altered. The functions <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  can accept an additional parameter for the random number generator. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from a variety of random number distributions. We plan to add a number of them:\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:41:44','2016-09-20 04:41:44','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9295,18607,'2016-09-20 00:45:03','2016-09-20 04:45:03','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between these PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. The method to generate a sequence of random numbers is slightly altered. The functions <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  can accept an additional parameter for the random number generator. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\n<h4></h4>\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from a variety of random number distributions. We plan to add a number of them:\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:45:03','2016-09-20 04:45:03','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9296,18607,'2016-09-20 00:48:24','2016-09-20 04:48:24','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">The API changes to incorporate user controlled random number generators has been minimal. The method to generate a sequence of random numbers is slightly altered. The functions <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  can accept an additional parameter for the random number generator. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\n&nbsp;\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from a variety of random number distributions. We plan to add a number of them:\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:48:24','2016-09-20 04:48:24','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9297,18607,'2016-09-20 00:52:02','2016-09-20 04:52:02','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine that can be passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span>  and <span class=\"lang:default decode:true crayon-inline\">randn</span>. A random number generator can be initialized by specifying the random engine type and its seed.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\n&nbsp;\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from a variety of random number distributions. We plan to add a number of them:\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:52:02','2016-09-20 04:52:02','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9298,18607,'2016-09-20 00:57:15','2016-09-20 04:57:15','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and its seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true  crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from a variety of random number distributions. We plan to add a number of them:\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:57:15','2016-09-20 04:57:15','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9299,18607,'2016-09-20 00:58:57','2016-09-20 04:58:57','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and its seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from a variety of random number distributions. We plan to add a number of them:\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:58:57','2016-09-20 04:58:57','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9300,18607,'2016-09-20 00:59:49','2016-09-20 04:59:49','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and its seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from a variety of random number distributions. We plan to add a number of them:\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 00:59:49','2016-09-20 04:59:49','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9301,18607,'2016-09-20 01:04:42','2016-09-20 05:04:42','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and its seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nUsers are more than welcome to give us inputs about their requirements on the ArrayFire <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 01:04:42','2016-09-20 05:04:42','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9302,18607,'2016-09-20 01:06:15','2016-09-20 05:06:15','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nUsers are more than welcome to give us inputs about their requirements on the ArrayFire <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 01:06:15','2016-09-20 05:06:15','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9303,18607,'2016-09-20 01:07:07','2016-09-20 05:07:07','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_PHILOX);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_MERSENNE);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_DEFAULT);\r\naf::array R = af::randu(elem, f32);</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nUsers are more than welcome to give us inputs about their requirements on the ArrayFire <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 01:07:07','2016-09-20 05:07:07','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9304,4,'2016-09-21 22:15:04','2016-09-22 02:15:04','There are a number of  additions and updates to image based features in the new v3.4 release of ArrayFire. Among the updates are:\n<ul>\n 	<li>New interpolation methods for several existing functions\n<ul>\n 	<li><a href=\"http://arrayfire.org/docs/group__signal__func__approx1.htm\">approx1</a>, <a href=\"http://arrayfire.org/docs/group__signal__func__approx2.htm\">approx2</a></li>\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__transform.htm\">transform</a></li>\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__resize.htm\">resize</a></li>\n</ul>\n</li>\n 	<li>Functions for image <a href=\"http://arrayfire.org/docs/group__image__func__moments.htm\">moments</a></li>\n</ul>\nThis blog post will display some typical use cases for these new features.\n\n<span style=\"line-height: 1.5;\">[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Interpolation methods[/custom_headline]</span>\n\nArrayFire v3.4 implements several new <a href=\"http://arrayfire.org/docs/defines_8h.htm#ac0b7c1cfd1fb146314d96f17bbfffa68\"> interpolation methods </a>for 1-d and 2-d domains. The new interpolation methods for 1-d functions are:\n<ul>\n 	<li><strong>AF_INTERP_LINEAR_COSINE</strong></li>\n 	<li><strong>AF_INTERP_CUBIC</strong></li>\n</ul>\nand for 2-d functions are:\n<ul>\n 	<li><strong>AF_INTERP_BILINEAR_COSINE</strong></li>\n 	<li><strong>AF_INTERP_BICUBIC</strong></li>\n</ul>\nThe behavior of the <a href=\"http://arrayfire.org/docs/defines_8h.htm#ac0b7c1cfd1fb146314d96f17bbfffa68\">interpolation methods</a> can be seen in the following pictures.\n\n&nbsp;\n\n[caption id=\"attachment_9338\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_0.png\"><img class=\"size-medium wp-image-9338\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_0-300x271.png\" alt=\"Original data points\" width=\"300\" height=\"271\" /></a> Original data points[/caption]\n\n[caption id=\"attachment_9339\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_1.png\"><img class=\"size-medium wp-image-9339\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_1-300x267.png\" alt=\"Linear interpolation\" width=\"300\" height=\"267\" /></a> Linear interpolation[/caption]\n\n[caption id=\"attachment_9340\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_2.png\"><img class=\"size-medium wp-image-9340\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_2-300x252.png\" alt=\"Linear cosine interpolation\" width=\"300\" height=\"252\" /></a> Linear cosine interpolation[/caption]\n\n[caption id=\"attachment_9337\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_3.png\"><img class=\"size-medium wp-image-9337\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_3-300x255.png\" alt=\"Cubic interpolation\" width=\"300\" height=\"255\" /></a> Cubic interpolation[/caption]\n\nA common use for interpolation is image filtering. Given a coarse image, we can resample it to be smoother.\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\n\n//define sample points for interpolation\naf::array Xs = af::seq(0, 6, 0.1f);\naf::array Ys = af::seq(0, 6, 0.1f);\nXs = af::tile(Xs, 1, Ys.dims(0));\nYs = af::tile(Ys.T(), Xs.dims(0));\n\n//interpolate based on specific method\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\n\nThe new interpolation methods further apply to several similar image transformation functions:\n<ul>\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__resize.htm\">Resize</a></li>\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__rotate.htm\">Rotate</a></li>\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__scale.htm\">Scale</a></li>\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__skew.htm\">Skew</a></li>\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__transform.htm\">Transform</a></li>\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__translate.htm\">Translate</a></li>\n</ul>\nDifferent interpolation methods greatly affect the final result of image processing operations. In general, bilinear and bilinear-cosine produce a good result when upscaling an image, however they often result in a blurry look. The bicubic method tends to sharpen the image resulting in slightly stronger borders and a better overall look. Below are some examples of this behavior using image rotation and image scaling.\n\n[caption id=\"attachment_9331\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_0.png\"><img class=\"size-medium wp-image-9331\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_0-300x84.png\" alt=\"3x image scaling using nearest-neighbor sampling\" width=\"300\" height=\"84\" /></a> 3x image scaling using nearest-neighbor sampling[/caption]\n\n[caption id=\"attachment_9332\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_1.png\"><img class=\"size-medium wp-image-9332\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_1-300x85.png\" alt=\"3x image scaling using bilinear-cosine sampling\" width=\"300\" height=\"85\" /></a> 3x image scaling using bilinear-cosine sampling[/caption]\n\n[caption id=\"attachment_9334\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_2.png\"><img class=\"size-medium wp-image-9334\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_2-300x85.png\" alt=\"3x image scaling using bicubic sampling\" width=\"300\" height=\"85\" /></a> 3x image scaling using bicubic sampling[/caption]\n\n[block_grid type=\"four-up\"] [block_grid_item]\n\n[caption id=\"attachment_9335\" align=\"aligncenter\" width=\"150\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_0.png\"><img class=\"wp-image-9335 size-thumbnail\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_0-150x150.png\" alt=\"rot_0\" width=\"150\" height=\"150\" /></a> Image rotation with nearest neighbor sampling.[/caption]\n\n[/block_grid_item][block_grid_item]\n\n[caption id=\"attachment_9336\" align=\"aligncenter\" width=\"150\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_1.png\"><img class=\"wp-image-9336 size-thumbnail\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_1-150x150.png\" alt=\"rot_1\" width=\"150\" height=\"150\" /></a> Image rotation with bilinear sampling.[/caption]\n\n[/block_grid_item][block_grid_item]\n\n[caption id=\"attachment_9329\" align=\"aligncenter\" width=\"150\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_2.png\"><img class=\"wp-image-9329 size-thumbnail\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_2-150x150.png\" alt=\"rot_2\" width=\"150\" height=\"150\" /></a> Image rotation with bilinear-cosine sampling.[/caption]\n\n[/block_grid_item][block_grid_item]\n\n[caption id=\"attachment_9330\" align=\"aligncenter\" width=\"150\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_3.png\"><img class=\"wp-image-9330 size-thumbnail\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_3-150x150.png\" alt=\"rot_3\" width=\"150\" height=\"150\" /></a> Image rotation with bicubic sampling.[/caption]\n\n[/block_grid_item][block_grid_item]\n\n[/block_grid]\n\n<span style=\"line-height: 1.5;\">[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Image moments[/custom_headline]</span>\n\nImage <a href=\"http://arrayfire.org/docs/group__image__func__moments.htm\">moments </a>are another new addition to ArrayFire v3.4. Image moments are weighted averages of pixels in an image which provide useful properties of an image. A common use of image moments is to find the center of mass or area (or gray level sum) of an image.\n\nCurrently, ArrayFire calculates all<a href=\"http://arrayfire.org/docs/defines_8h.htm#ad3ee8e32709131cf4126dfa26210aec0\"> first order moments</a>. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\n<div class=\"fragment\">\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area and center of mass of an image:</div>\n</div>\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\n\ndouble area = m00;\ndouble x_center = m10 / m00;\ndouble y_center = m01 / m00;\n</pre>\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\n\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Download[/custom_headline]\n\nArrayFire v3.4 can be downloaded from these locations:\n<ul>\n 	<li><a href=\"http://sandbox.arrayfire.com/download/\">Binaries</a></li>\n 	<li><a href=\"https://github.com/arrayfire\">Source code</a></li>\n</ul>\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Community[/custom_headline]\n\nArrayFire is continually improving through the addition of new image processing and computer vision functions. We welcome your feedback:\n<ul>\n 	<li>General discussion forums on the <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">ArrayFire Google Group</a></li>\n 	<li>Live discussion chat on the <a href=\"https://gitter.im/arrayfire/arrayfire?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\">ArrayFire Gitter</a></li>\n 	<li>Issue reports on the <a href=\"https://github.com/arrayfire/arrayfire/issues\">ArrayFire GitHub</a></li>\n</ul>\nFinally, as you find success with ArrayFire, we invite you to contribute a post to this blog to share with the broader community. Email <a href=\"mailto:scott@arrayfire.com\">scott@arrayfire.com</a> to contribute to this blog.','Image Processing Functions in ArrayFire v3.4','','inherit','closed','closed','','9166-autosave-v1','','','2016-09-21 22:15:04','2016-09-22 02:15:04','',9166,'http://sandbox.arrayfire.com/9166-autosave-v1/',0,'revision','',0),(9305,11,'2016-09-20 10:47:10','2016-09-20 14:47:10','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored, hence reducing the size in memory. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless. We have added a function, <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a>, that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\nMore details can be found on the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse documentation for ArrayFire</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)</a>\r\n<ul>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is inline with making the usage of sparse arrays seamless with regular arrays.\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\n<h4>Future Improvements</h4>\r\nWith the basic support for sparse arrays now complete, we can move forward to add more functionality that supports sparse arrays. Some of the features we are looking forwards to are:\r\n<ul>\r\n<li>Adding CSC support</li>\r\n<li>Storage format conversion between CSR, CSC, COO</li>\r\n<li>Matrix Multiplcation with CSC</li>\r\n<li>Sparse-Sparse Matrix Multiplcation (SPGEMM)</li>\r\n<li>Arithmetic operation support</li>\r\n</ul>\r\n\r\nThe <a href=\"https://github.com/arrayfire/arrayfire\">ArrayFire</a> GitHub page is the place for all updates on features and improvements to ArrayFire. You can also add your requests for features you would like to see added.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-20 10:47:10','2016-09-20 14:47:10','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9306,18607,'2016-09-20 10:50:15','2016-09-20 14:50:15','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nUsers are more than welcome to give us inputs about their requirements on the ArrayFire <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page.\r\n\r\nWe look forward to your feedback on the improved random number generation and any feature requests to improve it further.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 10:50:15','2016-09-20 14:50:15','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9307,18607,'2016-09-20 11:02:44','2016-09-20 15:02:44','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nWe look forward to your feedback on the improved random number generation and any feature requests to improve it further. Join us on the ArrayFire <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page or the ArrayFire <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">Google Group</a> to contribute to the discussion.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 11:02:44','2016-09-20 15:02:44','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9308,18607,'2016-09-20 11:03:34','2016-09-20 15:03:34','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn ArrayFire v3.4, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\n//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nWe look forward to your feedback on the improved random number generation and any feature requests to improve it further. Join us on the ArrayFire <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page or the ArrayFire <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">Google Group</a> to contribute to the discussion.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 11:03:34','2016-09-20 15:03:34','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9309,18607,'2016-09-20 11:15:14','2016-09-20 15:15:14','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn <strong>ArrayFire v3.4</strong>, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\n//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nWe look forward to your feedback on the improved random number generation and any feature requests to improve it further. Join us on the ArrayFire <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page or the ArrayFire <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">Google Group</a> to contribute to the discussion.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 11:15:14','2016-09-20 15:15:14','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9310,11,'2016-09-20 11:15:53','2016-09-20 15:15:53','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast variety of users. As the sizes of computation data has grown exponentially over the last few years, our users have been clamoring us for ways to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored, hence reducing the size in memory. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many formats to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless. We have added a function, <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a>, that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\nMore details can be found on the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse documentation for ArrayFire</a>.\r\n\r\n<h4>Sparse Functions</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)</a>\r\n<ul>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is inline with making the usage of sparse arrays seamless with regular arrays.\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.\r\n\r\n<h4>Example</h4>\r\n\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\n<h4>Future Improvements</h4>\r\nWith the basic support for sparse arrays now complete, we can move forward to add more functionality that supports sparse arrays. Some of the features we are looking forwards to are:\r\n<ul>\r\n<li>Adding CSC support</li>\r\n<li>Storage format conversion between CSR, CSC, COO</li>\r\n<li>Matrix Multiplcation with CSC</li>\r\n<li>Sparse-Sparse Matrix Multiplcation (SPGEMM)</li>\r\n<li>Arithmetic operation support</li>\r\n</ul>\r\n\r\nThe <a href=\"https://github.com/arrayfire/arrayfire\">ArrayFire</a> GitHub page is the place for all updates on features and improvements to ArrayFire. You can also add your requests for features you would like to see added.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-20 11:15:53','2016-09-20 15:15:53','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),(9311,18607,'2016-09-20 11:20:46','2016-09-20 15:20:46','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn <strong>ArrayFire v3.4</strong>, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\n//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n&nbsp;\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nWe look forward to your feedback on the improved random number generation and any feature requests to improve it further. Join us on our <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page, <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">Google Group</a> or <a href=\"https://gitter.im/arrayfire/arrayfire?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\">Gitter</a> to contribute to the discussion.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 11:20:46','2016-09-20 15:20:46','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9312,18607,'2016-09-20 11:56:52','2016-09-20 15:56:52','','CUDA Backend Performance','','inherit','open','closed','','cuda','','','2016-09-20 11:58:07','2016-09-20 15:58:07','',9269,'http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png',0,'attachment','image/png',0),(9313,18607,'2016-09-20 11:56:52','2016-09-20 15:56:52','','OpenCL Backend Performance','','inherit','open','closed','','opencl-3','','','2016-09-20 11:57:57','2016-09-20 15:57:57','',9269,'http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png',0,'attachment','image/png',0),(9314,18607,'2016-09-20 11:57:13','2016-09-20 15:57:13','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn <strong>ArrayFire v3.4</strong>, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\n//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\"><img class=\"alignnone size-medium wp-image-9312\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda-300x186.png\" alt=\"cuda\" width=\"300\" height=\"186\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\"><img class=\"alignnone size-medium wp-image-9313\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl-300x186.png\" alt=\"opencl\" width=\"300\" height=\"186\" /></a>\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nWe look forward to your feedback on the improved random number generation and any feature requests to improve it further. Join us on our <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page, <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">Google Group</a> or <a href=\"https://gitter.im/arrayfire/arrayfire?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\">Gitter</a> to contribute to the discussion.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 11:57:13','2016-09-20 15:57:13','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9315,18607,'2016-09-20 11:58:21','2016-09-20 15:58:21','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn <strong>ArrayFire v3.4</strong>, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\n//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\"><img class=\"aligncenter size-full wp-image-9312\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\" alt=\"CUDA Backend Performance\" width=\"600\" height=\"371\" /></a> <a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\"><img class=\"aligncenter size-full wp-image-9313\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\" alt=\"OpenCL Backend Performance\" width=\"600\" height=\"371\" /></a>\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nWe look forward to your feedback on the improved random number generation and any feature requests to improve it further. Join us on our <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page, <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">Google Group</a> or <a href=\"https://gitter.im/arrayfire/arrayfire?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\">Gitter</a> to contribute to the discussion.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 11:58:21','2016-09-20 15:58:21','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9316,18607,'2016-09-20 11:59:00','2016-09-20 15:59:00','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn <strong>ArrayFire v3.4</strong>, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\n//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n[caption id=\"attachment_9312\" align=\"aligncenter\" width=\"600\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\"><img class=\"wp-image-9312 size-full\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\" alt=\"CUDA Backend Performance\" width=\"600\" height=\"371\" /></a> CUDA Backend Performance[/caption]\r\n\r\n[caption id=\"attachment_9313\" align=\"aligncenter\" width=\"600\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\"><img class=\"wp-image-9313 size-full\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\" alt=\"OpenCL Backend Performance\" width=\"600\" height=\"371\" /></a> OpenCL Backend Performance[/caption]\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nWe look forward to your feedback on the improved random number generation and any feature requests to improve it further. Join us on our <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page, <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">Google Group</a> or <a href=\"https://gitter.im/arrayfire/arrayfire?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\">Gitter</a> to contribute to the discussion.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 11:59:00','2016-09-20 15:59:00','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9317,18607,'2016-09-20 13:08:02','2016-09-20 17:08:02','<span style=\"font-weight: 400;\">Pseudorandom number generators are an integral part of many applications in statistics, modeling and simulations. ArrayFire therefore has provided high performant solutions to generate random numbers. The PRNG algorithms used in earlier versions were platform specific :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CUDA : XORWOW</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">OpenCL : Threefry</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU : Mersenne Twister</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">While simple uses of random numbers would not have been affected by the differences in the engines, more rigorous requirements of randomness could not have been consistently provided by the earlier solutions.</span>\r\n\r\n<span style=\"font-weight: 400;\">A new class of PRNGs have emerged that have interesting statistical and computational performance called the <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a>. These random number generators have two major advantages over Mersenne Twister(MT) which has been the standard for random number generation :</span>\r\n<ol>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance : CBRNGs pass rigorous and extensive statistical tests as opposed to MT and XORWOW.</span></li>\r\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space : The amount of storage space required to maintain state of the random engines is minimal compared to MT.</span></li>\r\n</ol>\r\n<span style=\"font-weight: 400;\">Given these advantages, ArrayFire now includes Philox and Threefry algorithms which are counter based. </span>While certain PRNGs might seem more attractive in terms of performance, statistical or computational, it is our aim to provide users with the freedom to decide what tools might be most suitable to their requirements. Therefore, Mersenne Twister algorithm has been implemented for use as well.\r\n\r\nIn <strong>ArrayFire v3.4</strong>, users can select between the following PRNGs :\r\n<ol>\r\n 	<li>Philox (CBRNG)</li>\r\n 	<li>Threefry (CBRNG)</li>\r\n 	<li>Mersenne Twister</li>\r\n</ol>\r\n<h4>Usage</h4>\r\n<span style=\"font-weight: 400;\">Users can create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed and are then passed onto <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> which generate the sequence of random numbers.</span>\r\n<pre class=\"lang:c++ decode:true\">unsigned seed;\r\nunsigned elem;\r\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\r\naf::array R = af::randu(elem, f32, rp);</pre>\r\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine without needing to alter these function calls in the code base. These default random engines contain the state of the engine and can be reset or changed as required by the user.\r\n<pre class=\"lang:c++ decode:true \">unsigned seed;\r\nsetSeed(seed);\r\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\r\n//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\r\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\r\nAs of now, the default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> . For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\r\n<h4>Performance Numbers</h4>\r\n[caption id=\"attachment_9312\" align=\"aligncenter\" width=\"600\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\"><img class=\"wp-image-9312 size-full\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\" alt=\"OpenCL Backend Performance\" width=\"600\" height=\"371\" /></a> OpenCL Backend Performance[/caption]\r\n\r\n[caption id=\"attachment_9313\" align=\"aligncenter\" width=\"600\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\"><img class=\"wp-image-9313 size-full\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\" alt=\"CUDA Backend Performance\" width=\"600\" height=\"371\" /></a> CUDA Backend Performance[/caption]\r\n<h4>Future Plans</h4>\r\nXORWOW and MRG32K3a random engines will be added in the future. Apart from random engines, users can also benefit from the following random number distributions which are planned for inclusion in subsequent releases :\r\n<ul>\r\n 	<li class=\"task-list-item enabled hovered\">Exponential</li>\r\n 	<li class=\"task-list-item enabled\">Gamma</li>\r\n 	<li class=\"task-list-item enabled\">Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Non-central Chi-squared</li>\r\n 	<li class=\"task-list-item enabled\">Poisson</li>\r\n</ul>\r\nWe look forward to your feedback on the improved random number generation and any feature requests to improve it further. Join us on our <a href=\"https://github.com/arrayfire/arrayfire\">GitHub</a> page, <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">Google Group</a> or <a href=\"https://gitter.im/arrayfire/arrayfire?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\">Gitter</a> to contribute to the discussion.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-revision-v1','','','2016-09-20 13:08:02','2016-09-20 17:08:02','',9269,'http://sandbox.arrayfire.com/9269-revision-v1/',0,'revision','',0),(9318,4,'2016-09-20 13:50:01','2016-09-20 17:50:01','There are a number of  additions and updates to image based features in the new v3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li>approx1, approx2</li>\r\n 	<li>transform</li>\r\n 	<li>resize</li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image moments</li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5;\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods for 1-d functions are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_LINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_CUBIC</strong></li>\r\n</ul>\r\nand for 2-d functions are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_BILINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_BICUBIC</strong></li>\r\n</ul>\r\nThe behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> From Left to Right:  1) Raw Data, 2) Linear Interpolation, 3) Linear-Cosine Interpolation, 4) Cubic Interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can resample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolation methods further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li>Resize</li>\r\n 	<li>Rotate</li>\r\n 	<li>Scale</li>\r\n 	<li>Skew</li>\r\n 	<li>Transform</li>\r\n 	<li>Translate</li>\r\n</ul>\r\nDifferent interpolation methods greatly affect the final result of image processing operations. In general, bilinear and bilinear-cosine produce a good result when upscaling an image, however they often result in a blurry look. The bicubic method tends to sharpen the image resulting in slightly stronger borders and a better overall look. Below are some examples of this behavior using image rotation and image scaling.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9260\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png\"><img class=\"wp-image-9260 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality-300x119.png\" alt=\"Image rotation with different interpolation methods.\" width=\"300\" height=\"119\" /></a> Image rotation with different interpolation methods. Left to right: nearest neighbor, bilinear, bilinear cosine, cubic[/caption]\r\n\r\n[caption id=\"attachment_9261\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale.png\"><img class=\"size-medium wp-image-9261\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale-300x276.png\" alt=\"3x image scaling with different interpolation methods.\" width=\"300\" height=\"276\" /></a> 3x image scaling with different sampling methods. Top to bottom: nearest neighbor, bilinear cosine, bicubic[/caption]\r\n\r\n<span style=\"line-height: 1.5;\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nImage moments are another new addition to ArrayFire v3.4. Image moments are weighted averages of pixels in an image which provide useful properties of an image. A common use of image moments is to find the center of mass or area (or gray level sum) of an image.\r\n\r\nCurrently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\n[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Download[/custom_headline]\r\n\r\nArrayFire v3.4 can be downloaded from these locations:\r\n<ul>\r\n 	<li><a href=\"http://sandbox.arrayfire.com/download/\">Binaries</a></li>\r\n 	<li><a href=\"https://github.com/arrayfire\">Source code</a></li>\r\n</ul>\r\n[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Community[/custom_headline]\r\n\r\nArrayFire is continually improving through the addition of new image processing and computer vision functions. We look forward to hearing your feedback on our user group and encourage you to share your ArrayFire stories there to inspire and contribute back to our open source community.','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-20 13:50:01','2016-09-20 17:50:01','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9320,4,'2016-09-21 13:38:26','2016-09-21 17:38:26','<span style=\"font-weight: 400;\">Pseudorandom number generators (PRNGs) are an integral part of many applications in statistics, modeling, and simulations. In ArrayFire v3.4, we introduce random number generation enhancements that improve speed, accuracy, storage, and unity among the ArrayFire backends.</span>\n\n<span style=\"font-weight: 400;\">Previously in ArrayFire v3.3, each ArrayFire backend used a different PRNG. In ArrayFire v3.4, each ArrayFire backend is able to select from among 3 different random number generators.</span>\n<table>\n<tbody>\n<tr>\n<td colspan=\"2\">ArrayFire v3.3 (platform specific)</td>\n<td rowspan=\"4\"></td>\n<td colspan=\"2\">ArrayFire v3.4 (all generators on all platforms)</td>\n</tr>\n<tr>\n<td>CUDA</td>\n<td>XORWOW</td>\n<td rowspan=\"3\">CUDA,\nOpenCL,\nCPU</td>\n<td rowspan=\"3\">Philox (CBRNG),\nThreefry (CBRNG),\nMersenne Twister</td>\n</tr>\n<tr>\n<td>OpenCL</td>\n<td>Threefry (CBRNG)</td>\n</tr>\n<tr>\n<td>CPU</td>\n<td>Mersenne Twister</td>\n</tr>\n</tbody>\n</table>\n<span style=\"font-weight: 400;\">As seen above, the XORWOW generator (which was only available for CUDA devices previously) has been replaced by the Philox generator which is available along with Threefry and Mersenne Twister on all ArrayFire supported devices. Philox and Threefry are</span><span style=\"font-weight: 400;\"> <a href=\"http://www.thesalmons.org/john/random123/papers/random123sc11.pdf\">Counter Based Random Number Generators</a> (CBRNGs). CBRNGs have two major advantages over PRNGs:</span>\n<ol>\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Crush Resistance - CBRNGs pass rigorous and extensive statistical tests while Mersenne Twister and XORWOW are not as accurate.</span></li>\n 	<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Smaller Storage Space - The amount of storage space required to maintain the state of CBRNGs is minimal compared to Mersenne Twister.</span></li>\n</ol>\n<span style=\"font-weight: 400;\">For these reasons, ArrayFire v3.4 now includes both the Philox and Threefry CBRNGs. Mersenne Twister will continue to be maintained due to its ubiquity in technical computing.</span>\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Usage[/custom_headline]\n<span style=\"font-weight: 400;\">Users create a random engine object that contains the state of the engine. These objects are initialized by specifying the random engine type and seed. Then the objects are passed into the <span class=\"lang:default decode:true crayon-inline\">randu</span> and <span class=\"lang:default decode:true crayon-inline\">randn</span> functions which generate the sequence of random numbers.</span>\n<pre class=\"lang:c++ decode:true\">unsigned seed;\nunsigned elem;\naf::randomEngine rp(AF_RANDOM_ENGINE_PHILOX, seed);\naf::array R = af::randu(elem, f32, rp);</pre>\nAnother method to select a random engine algorithm is to set the default random engine type. If needed the desired seed can be specified as well. Subsequent calls to <span class=\"lang:default decode:true crayon-inline \">randu</span>  and <span class=\"lang:default decode:true crayon-inline \">randn</span>  will utilize the default random engine. These default random engines contain the state of the engine and can be reset or changed by the user.\n<pre class=\"lang:c++ decode:true \">unsigned seed;\nsetSeed(seed);\nsetDefaultRandomEngine(AF_RANDOM_ENGINE_THREEFRY);\n//Or AF_RANDOM_ENGINE_DEFAULT, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENGINE_MERSENNE\naf::array R = af::randu(elem, f32);//Utilizes threefry PRNG algorithm initialized with \'seed\'</pre>\nThe default random engine type is <span class=\"lang:default decode:true crayon-inline \">AF_RANDOM_ENGINE_PHILOX</span> because it has the best statistical properties among the available generators. For further details on usage, please refer to the <a href=\"http://arrayfire.org/docs/group__random__mat.htm\">documentation</a>.\n\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Performance Results[/custom_headline]\n\n[caption id=\"attachment_9312\" align=\"aligncenter\" width=\"600\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\"><img class=\"wp-image-9312 size-full\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/cuda.png\" alt=\"OpenCL Backend Performance\" width=\"600\" height=\"371\" /></a> OpenCL Backend Performance[/caption]\n\n[caption id=\"attachment_9313\" align=\"aligncenter\" width=\"600\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\"><img class=\"wp-image-9313 size-full\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/opencl.png\" alt=\"CUDA Backend Performance\" width=\"600\" height=\"371\" /></a> CUDA Backend Performance[/caption]\n\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Future Plans[/custom_headline]\n\nFuture releases of ArrayFire will include the XORWOW and MRG32K3a generators for all platforms.\n\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Download[/custom_headline]\n\nArrayFire v3.4 can be downloaded from these locations:\n<ul>\n 	<li><a href=\"http://sandbox.arrayfire.com/download/\">Binaries</a></li>\n 	<li><a href=\"https://github.com/arrayfire\">Source code</a></li>\n</ul>\n[custom_headline type=\"left\" level=\"h3\" looks_like=\"h3\"]Community[/custom_headline]\n\nArrayFire is continually improving through the addition of new random number generators and statistical functions. We welcome your feedback:\n<ul>\n 	<li>General discussion forums on the <a href=\"https://groups.google.com/forum/#!forum/arrayfire-users\">ArrayFire Google Group</a></li>\n 	<li>Live discussion chat on the <a href=\"https://gitter.im/arrayfire/arrayfire?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge\">ArrayFire Gitter</a></li>\n 	<li>Issue or bug reports on the <a href=\"https://github.com/arrayfire/arrayfire/issues\">ArrayFire GitHub</a></li>\n</ul>\nFinally, as you find success with ArrayFire, we invite you to contribute a post to this blog to share with the broader community. Email <a href=\"mailto:scott@arrayfire.com\">scott@arrayfire.com</a> to contribute to this blog.','Random Number Generators in ArrayFire v3.4','','inherit','closed','closed','','9269-autosave-v1','','','2016-09-21 13:38:26','2016-09-21 17:38:26','',9269,'http://sandbox.arrayfire.com/9269-autosave-v1/',0,'revision','',0),(9321,18673,'2016-09-20 19:23:27','2016-09-20 23:23:27','There are a number of  additions and updates to image based features in the new v3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__signal__func__approx1.htm\">approx1</a>, <a href=\"http://arrayfire.org/docs/group__signal__func__approx2.htm\">approx2</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__transform.htm\">transform</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__resize.htm\">resize</a></li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image <a href=\"http://arrayfire.org/docs/group__image__func__moments.htm\">moments</a></li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new <a href=\"http://arrayfire.org/docs/defines_8h.htm#ac0b7c1cfd1fb146314d96f17bbfffa68\"> interpolation methods </a>for 1-d and 2-d domains. The new interpolation methods for 1-d functions are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_LINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_CUBIC</strong></li>\r\n</ul>\r\nand for 2-d functions are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_BILINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_BICUBIC</strong></li>\r\n</ul>\r\nThe behavior of the <a href=\"http://arrayfire.org/docs/defines_8h.htm#ac0b7c1cfd1fb146314d96f17bbfffa68\">interpolation methods</a> can be seen in the following pictures.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9338\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_0.png\"><img class=\"size-medium wp-image-9338\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_0-300x271.png\" alt=\"Original data points\" width=\"300\" height=\"271\" /></a> Original data points[/caption]\r\n\r\n[caption id=\"attachment_9339\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_1.png\"><img class=\"size-medium wp-image-9339\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_1-300x267.png\" alt=\"Linear interpolation\" width=\"300\" height=\"267\" /></a> Linear interpolation[/caption]\r\n\r\n[caption id=\"attachment_9340\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_2.png\"><img class=\"size-medium wp-image-9340\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_2-300x252.png\" alt=\"Linear cosine interpolation\" width=\"300\" height=\"252\" /></a> Linear cosine interpolation[/caption]\r\n\r\n[caption id=\"attachment_9337\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_3.png\"><img class=\"size-medium wp-image-9337\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/ap1_3-300x255.png\" alt=\"Cubic interpolation\" width=\"300\" height=\"255\" /></a> Cubic interpolation[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can resample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolation methods further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__resize.htm\">Resize</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__rotate.htm\">Rotate</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__scale.htm\">Scale</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__skew.htm\">Skew</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__transform.htm\">Transform</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__translate.htm\">Translate</a></li>\r\n</ul>\r\nDifferent interpolation methods greatly affect the final result of image processing operations. In general, bilinear and bilinear-cosine produce a good result when upscaling an image, however they often result in a blurry look. The bicubic method tends to sharpen the image resulting in slightly stronger borders and a better overall look. Below are some examples of this behavior using image rotation and image scaling.\r\n\r\n[caption id=\"attachment_9331\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_0.png\"><img class=\"size-medium wp-image-9331\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_0-300x84.png\" alt=\"3x image scaling using nearest-neighbor sampling\" width=\"300\" height=\"84\" /></a> 3x image scaling using nearest-neighbor sampling[/caption]\r\n\r\n[caption id=\"attachment_9332\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_1.png\"><img class=\"size-medium wp-image-9332\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_1-300x85.png\" alt=\"3x image scaling using bilinear-cosine sampling\" width=\"300\" height=\"85\" /></a> 3x image scaling using bilinear-cosine sampling[/caption]\r\n\r\n[caption id=\"attachment_9334\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_2.png\"><img class=\"size-medium wp-image-9334\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/s_2-300x85.png\" alt=\"3x image scaling using bicubic sampling\" width=\"300\" height=\"85\" /></a> 3x image scaling using bicubic sampling[/caption]\r\n\r\n[block_grid type=\"four-up\"] [block_grid_item]\r\n\r\n[caption id=\"attachment_9335\" align=\"aligncenter\" width=\"150\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_0.png\"><img class=\"wp-image-9335 size-thumbnail\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_0-150x150.png\" alt=\"rot_0\" width=\"150\" height=\"150\" /></a> Image rotation with nearest neighbor sampling.[/caption]\r\n\r\n[/block_grid_item][block_grid_item]\r\n\r\n[caption id=\"attachment_9336\" align=\"aligncenter\" width=\"150\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_1.png\"><img class=\"wp-image-9336 size-thumbnail\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_1-150x150.png\" alt=\"rot_1\" width=\"150\" height=\"150\" /></a> Image rotation with bilinear sampling.[/caption]\r\n\r\n[/block_grid_item][block_grid_item]\r\n\r\n[caption id=\"attachment_9329\" align=\"aligncenter\" width=\"150\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_2.png\"><img class=\"wp-image-9329 size-thumbnail\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_2-150x150.png\" alt=\"rot_2\" width=\"150\" height=\"150\" /></a> Image rotation with bilinear-cosine sampling.[/caption]\r\n\r\n[/block_grid_item][block_grid_item]\r\n\r\n[caption id=\"attachment_9330\" align=\"aligncenter\" width=\"150\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_3.png\"><img class=\"wp-image-9330 size-thumbnail\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_3-150x150.png\" alt=\"rot_3\" width=\"150\" height=\"150\" /></a> Image rotation with bicubic sampling.[/caption]\r\n\r\n[/block_grid_item][block_grid_item]\r\n\r\n[/block_grid]\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nImage <a href=\"http://arrayfire.org/docs/group__image__func__moments.htm\">moments </a>are another new addition to ArrayFire v3.4. Image moments are weighted averages of pixels in an image which provide useful properties of an image. A common use of image moments is to find the center of mass or area (or gray level sum) of an image.\r\n\r\nCurrently, ArrayFire calculates all<a href=\"http://arrayfire.org/docs/defines_8h.htm#ad3ee8e32709131cf4126dfa26210aec0\"> first order moments</a>. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\n[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Download[/custom_headline]\r\n\r\nArrayFire v3.4 can be downloaded from these locations:\r\n<ul>\r\n 	<li><a href=\"http://sandbox.arrayfire.com/download/\">Binaries</a></li>\r\n 	<li><a href=\"https://github.com/arrayfire\">Source code</a></li>\r\n</ul>\r\n[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Community[/custom_headline]\r\n\r\nArrayFire is continually improving through the addition of new image processing and computer vision functions. We look forward to hearing your feedback on our user group and encourage you to share your ArrayFire stories there to inspire and contribute back to our open source community.','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-autosave-v1','','','2016-09-20 19:23:27','2016-09-20 23:23:27','',9166,'http://sandbox.arrayfire.com/9166-autosave-v1/',0,'revision','',0),(9322,18673,'2016-09-20 17:40:38','2016-09-20 21:40:38','There are a number of  additions and updates to image based features in the new v3.4 release of ArrayFire. Among the updates are:\r\n<ul>\r\n 	<li>New interpolation methods for several existing functions\r\n<ul>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__signal__func__approx1.htm\">approx1</a>, <a href=\"http://arrayfire.org/docs/group__signal__func__approx2.htm\">approx2</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__transform.htm\">transform</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__resize.htm\">resize</a></li>\r\n</ul>\r\n</li>\r\n 	<li>Functions for image <a href=\"http://arrayfire.org/docs/group__image__func__moments.htm\">moments</a></li>\r\n</ul>\r\nThis blog post will display some typical use cases for these new features.\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Interpolation methods[/custom_headline]</span>\r\n\r\nArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods for 1-d functions are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_LINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_CUBIC</strong></li>\r\n</ul>\r\nand for 2-d functions are:\r\n<ul>\r\n 	<li><strong>AF_INTERP_BILINEAR_COSINE</strong></li>\r\n 	<li><strong>AF_INTERP_BICUBIC</strong></li>\r\n</ul>\r\nThe behavior of the interpolation methods can be seen in the following picture.\r\n\r\n[caption id=\"attachment_9244\" align=\"aligncenter\" width=\"1701\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\"><img class=\"size-full wp-image-9244\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/approx1.png\" alt=\"Starting from raw data, to linear interpolation, then linear cosine interpolation. and finally cubic interpolation.\" width=\"1701\" height=\"430\" /></a> From Left to Right:  1) Raw Data, 2) Linear Interpolation, 3) Linear-Cosine Interpolation, 4) Cubic Interpolation.[/caption]\r\n\r\nA common use for interpolation is image filtering. Given a coarse image, we can resample it to be smoother.\r\n<pre class=\"lang:c++ decode:true\" title=\"Interpolating images with approx2()\">af::array img = af::randu(7,7); //create a random image\r\n\r\n//define sample points for interpolation\r\naf::array Xs = af::seq(0, 6, 0.1f);\r\naf::array Ys = af::seq(0, 6, 0.1f);\r\nXs = af::tile(Xs, 1, Ys.dims(0));\r\nYs = af::tile(Ys.T(), Xs.dims(0));\r\n\r\n//interpolate based on specific method\r\naf::array img_bilinear = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR);\r\naf::array img_bilinearcos = af::approx2(img, Xs, Ys, AF_INTERP_BILINEAR_COSINE);\r\naf::array img_bicubic = af::approx2(img, Xs, Ys, AF_INTERP_BICUBIC_SPLINE);</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\"><img class=\"aligncenter size-full wp-image-9245\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/Capture.png\" alt=\"Capture\" width=\"1025\" height=\"243\" /></a>\r\n\r\nThe new interpolation methods further apply to several similar image transformation functions:\r\n<ul>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__resize.htm\">Resize</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__rotate.htm\">Rotate</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__scale.htm\">Scale</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__skew.htm\">Skew</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__transform.htm\">Transform</a></li>\r\n 	<li><a href=\"http://arrayfire.org/docs/group__transform__func__translate.htm\">Translate</a></li>\r\n</ul>\r\nDifferent interpolation methods greatly affect the final result of image processing operations. In general, bilinear and bilinear-cosine produce a good result when upscaling an image, however they often result in a blurry look. The bicubic method tends to sharpen the image resulting in slightly stronger borders and a better overall look. Below are some examples of this behavior using image rotation and image scaling.\r\n\r\n&nbsp;\r\n\r\n[caption id=\"attachment_9260\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality.png\"><img class=\"wp-image-9260 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/rot_quality-300x119.png\" alt=\"Image rotation with different interpolation methods.\" width=\"300\" height=\"119\" /></a> Image rotation with different interpolation methods. Left to right: nearest neighbor, bilinear, bilinear cosine, cubic[/caption]\r\n\r\n[caption id=\"attachment_9261\" align=\"aligncenter\" width=\"300\"]<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale.png\"><img class=\"size-medium wp-image-9261\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/scale-300x276.png\" alt=\"3x image scaling with different interpolation methods.\" width=\"300\" height=\"276\" /></a> 3x image scaling with different sampling methods. Top to bottom: nearest neighbor, bilinear cosine, bicubic[/caption]\r\n\r\n<span style=\"line-height: 1.5\">[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Image moments[/custom_headline]</span>\r\n\r\nImage <a href=\"http://arrayfire.org/docs/group__image__func__moments.htm\">moments </a>are another new addition to ArrayFire v3.4. Image moments are weighted averages of pixels in an image which provide useful properties of an image. A common use of image moments is to find the center of mass or area (or gray level sum) of an image.\r\n\r\nCurrently, ArrayFire calculates all<a href=\"http://arrayfire.org/docs/defines_8h.htm#ad3ee8e32709131cf4126dfa26210aec0\"> first order moments</a>. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:\r\n<pre class=\"lang:c++ decode:true\">af::array moments = af::moments(input_image, AF_MOMENT_FIRST_ORDER);</pre>\r\n<div class=\"fragment\">\r\n<div class=\"line\">Here is an example of how the shorthand versions might be used to find the area and center of mass of an image:</div>\r\n</div>\r\n<pre class=\"lang:default decode:true\" title=\"Calculating center of mass of grayscale image\">double m00, m01, m10;\r\naf::moments(&amp;m00, aimg, AF_MOMENT_M00);\r\naf::moments(&amp;m01, aimg, AF_MOMENT_M01);\r\naf::moments(&amp;m10, aimg, AF_MOMENT_M10);\r\n\r\ndouble area = m00;\r\ndouble x_center = m10 / m00;\r\ndouble y_center = m01 / m00;\r\n</pre>\r\n<a href=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com.png\"><img class=\"aligncenter wp-image-9246 size-medium\" src=\"http://sandbox.arrayfire.com/wp-content/uploads/2016/09/com-300x300.png\" alt=\"com\" width=\"300\" height=\"300\" /></a>\r\n\r\n[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Download[/custom_headline]\r\n\r\nArrayFire v3.4 can be downloaded from these locations:\r\n<ul>\r\n 	<li><a href=\"http://sandbox.arrayfire.com/download/\">Binaries</a></li>\r\n 	<li><a href=\"https://github.com/arrayfire\">Source code</a></li>\r\n</ul>\r\n[custom_headline type=\"left\" level=\"h2\" looks_like=\"h2\"]Community[/custom_headline]\r\n\r\nArrayFire is continually improving through the addition of new image processing and computer vision functions. We look forward to hearing your feedback on our user group and encourage you to share your ArrayFire stories there to inspire and contribute back to our open source community.','New image-based features in ArrayFire v3.4','','inherit','closed','closed','','9166-revision-v1','','','2016-09-20 17:40:38','2016-09-20 21:40:38','',9166,'http://sandbox.arrayfire.com/9166-revision-v1/',0,'revision','',0),(9323,11,'2016-09-20 18:08:57','2016-09-20 22:08:57','With the release of <strong>ArrayFire v3.4</strong>, we have added a number of features that will help our vast range of users. Our users have been asking us for a way to reduce the memory footprint of their data on the GPU. And now we have answered our users\' requests.\r\nIntroducing Sparse Matrices in ArrayFire!\r\n\r\n<h4>Sparse Data Structure</h4>\r\nA sparse data structure is one where all the non-zero elements are not stored. Sparse matrices are useful when the number of zero-values elements are &gt;&gt; number of non-zero elements (sparsity of the matrix is high).\r\nThe sparse data structure in general is stored as 3 arrays.\r\n<ul>\r\n<li>A data or values array containing all the non-zero elements</li>\r\n<li>A vector for row indices (based on storage format).</li>\r\n<li>A vector for column indices (based on storage format).</li>\r\n</ul>\r\n\r\nThere are many ways to store sparse matrices, the most prominent of which are\r\n<ul>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29\">Compressed Sparse Row</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29\">Compressed Storage Column</a></li>\r\n<li><a href=\"https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_.28COO.29\">Coordinate Format</a>.</li>\r\n</ul>\r\n\r\nArrayFire supports CSR and COO format, with CSC support coming in future releases.\r\n\r\nA more detailed description of Sparse Matrix can be found on <a href=\"https://en.wikipedia.org/wiki/Sparse_matrix\">Wikipedia</a>.\r\n\r\n<h4>Sparse in ArrayFire</h4>\r\nIn ArrayFire, Sparse arrays use the same user facing object - af::array. This makes working with sparse arrays all the more seamless.\r\nWe have added a function <a href=\"http://arrayfire.org/docs/group__method__mat.htm#ga5945f95549bae25f75694a69d98ca584\">af::array::issparse()</a> that allows users to check if an array is sparse or not.\r\nAlthough externally, there is no difference between a sparse and dense array, internally, the sparse array is stored as 3 independent arrays along with other meta data.\r\nThese arrays, as well as other properties can be fetched using the <a href=\"http://arrayfire.org/docs/group__sparse__func.htm\">sparse functions</a>.\r\n\r\n<h4>Sparse Functionality</h4>\r\nAs of v3.4, the following features are supported for sparse arrays:\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm\">Creation for sparse arrays.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae4621e58bfaf6d80668309824fde86c0\">From 3 (data, row, column) sparse host or device memory vectors.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gae9a843c7e93b05e6b090ca32b271ebe9\">From 3 (data, row, column) sparse af::arrays.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">From dense af::array.</a></li>\r\n<li>To create a sparse array from host or device dense array, first create a dense af::array, and then pass it to create sparse af::array from dense af::array.</li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__convert__to.htm\">Storage format conversions.</a>\r\n<ul>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__create.htm#gac0d367d8c9daf27b36a6981bbfcdb970\">Dense to CSR/COO.</a></li>\r\n<li><a href=\"http://arrayfire.org/docs/group__sparse__func__dense.htm\">CSR/COO to dense.</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">Sparse-Dense Matrix Multiplication (SPMM/SPMV)</a>\r\n<ul>\r\n<li>Sparse Matrix - Dense Matrix</li>\r\n<li>Sparse Matrix - Dense Vector</li>\r\n<li>Options for Sparse Matrix to be transposed.</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n\r\nThe Sparse-Dense Matrix Multiplcation is a implemented as a part of <a href=\"http://arrayfire.org/docs/group__blas__func__matmul.htm#ga63306b6ed967bd1055086db862fe885b\">af::matmul()</a>. This is part of making the usage of sparse arrays seamless with regular arrays.\r\n\r\n<h4>Example</h4>\r\n<pre>\r\n/*******************************************************\r\n * Copyright (c) 2014, ArrayFire\r\n * All rights reserved.\r\n *\r\n * This file is distributed under 3-clause BSD license.\r\n * The complete license agreement can be obtained at:\r\n * http://sandbox.arrayfire.com/licenses/BSD-3-Clause\r\n ********************************************************/\r\n#include <arrayfire.h>\r\n#include <iostream>\r\n\r\nusing namespace af;\r\n\r\nstatic size_t dimension = 16 * 1024;\r\nstatic const int maxIter = 10;\r\nstatic const int sparsityFactor = 7;\r\n\r\nstatic array A;\r\nstatic array As;  // Sparse A\r\nstatic array x0;\r\nstatic array b;\r\n\r\nvoid setupInputs()\r\n{\r\n    // Generate a random input: A\r\n    array T = randu(dimension, dimension, f32);\r\n    // Create 0s in input.\r\n    // Anything that is no divisible by sparsityFactor will become 0.\r\n    A = floor(T * 1000);\r\n    A = A * ((A % sparsityFactor) == 0) / 1000;\r\n    // Make it positive definite\r\n    A = transpose(A) + A + A.dims(0)*identity(A.dims(0), A.dims(0), f32);\r\n\r\n    // Make A sparse as As\r\n    As = sparse(A);\r\n\r\n    // Generate x0: Random guess\r\n    x0 = randu(A.dims(0), f32);\r\n\r\n    //Generate b\r\n    b = matmul(A, x0);\r\n\r\n    // Run evals on inputs\r\n    A .eval();\r\n    sparseGetValues(As).eval();\r\n    sparseGetRowIdx(As).eval();\r\n    sparseGetColIdx(As).eval();\r\n    x0.eval();\r\n    b .eval();\r\n    af::sync();\r\n}\r\n\r\nvoid sparseConjugateGradient(void)\r\n{\r\n    array x = constant(0, b.dims(), f32);\r\n    array r = b - matmul(As, x);\r\n    array p = r;\r\n\r\n    for (int i = 0; i < maxIter; ++i) {\r\n        array Ap = matmul(As, p);\r\n        array alpha_num = dot(r, r);\r\n        array alpha_den = dot(p, Ap);\r\n        array alpha = alpha_num/alpha_den;\r\n        r = r - tile(alpha, Ap.dims())*Ap;\r\n        x = x + tile(alpha, Ap.dims())*p;\r\n        array beta_num = dot(r, r);\r\n        array beta = beta_num/alpha_num;\r\n        p = r + tile(beta, p.dims())*p;\r\n    }\r\n}\r\n\r\nvoid denseConjugateGradient(void)\r\n{\r\n    array x = constant(0, b.dims(), f32);\r\n    array r = b - matmul(A, x);\r\n    array p = r;\r\n\r\n    for (int i = 0; i < maxIter; ++i) {\r\n        array Ap = matmul(A, p);\r\n        array alpha_num = dot(r, r);\r\n        array alpha_den = dot(p, Ap);\r\n        array alpha = alpha_num/alpha_den;\r\n        r = r - tile(alpha, Ap.dims())*Ap;\r\n        x = x + tile(alpha, Ap.dims())*p;\r\n        array beta_num = dot(r, r);\r\n        array beta = beta_num/alpha_num;\r\n        p = r + tile(beta, p.dims())*p;\r\n    }\r\n}\r\n\r\nvoid checkConjugateGradient(const af::array in)\r\n{\r\n    array x = constant(0, b.dims(), f32);\r\n    array r = b - matmul(in, x);\r\n    array p = r;\r\n\r\n    for (int i = 0; i < maxIter; ++i) {\r\n        array Ap = matmul(in, p);\r\n        array alpha_num = dot(r, r);\r\n        array alpha_den = dot(p, Ap);\r\n        array alpha = alpha_num/alpha_den;\r\n        r = r - tile(alpha, Ap.dims())*Ap;\r\n        x = x + tile(alpha, Ap.dims())*p;\r\n        array beta_num = dot(r, r);\r\n        array beta = beta_num/alpha_num;\r\n        p = r + tile(beta, p.dims())*p;\r\n    }\r\n    array res = x0 - x;\r\n\r\n    std::cout<<\"Final difference in solutions:\\n\";\r\n    af_print(dot(res, res));\r\n}\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n    af::info();\r\n    setupInputs();\r\n\r\n    std::cout << \"Verifying Dense Conjugate Gradient:\" << std::endl;\r\n    checkConjugateGradient(A);\r\n\r\n    std::cout << \"Verifying Sparse Conjugate Gradient:\" << std::endl;\r\n    checkConjugateGradient(As);\r\n\r\n    af::sync();\r\n\r\n    std::cout<< \"Dense Conjugate Gradient Time: \" << timeit(denseConjugateGradient) * 1000 << \"ms\" << std::endl;\r\n    af::sync();\r\n\r\n    std::cout<< \"Sparse Conjugate Gradient Time: \" << timeit(sparseConjugateGradient) * 1000 << \"ms\" << std::endl;\r\n    af::sync();\r\n\r\n    return 0;\r\n}\r\n</pre>\r\n<h4>Performance and Memory Footprint</h4>\r\n\r\nAs with all ArrayFire features, Sparse support is available across all backends and all architectures.','Sparse Matrices in ArrayFire','','inherit','closed','closed','','9190-revision-v1','','','2016-09-20 18:08:57','2016-09-20 22:08:57','',9190,'http://sandbox.arrayfire.com/9190-revision-v1/',0,'revision','',0),