Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
cmake_minimum_required(VERSION 3.0)
cmake_policy(VERSION 3.5)
project(ArrayFire-Examples
VERSION 3.5.0
VERSION 3.7.0
LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 98)
if(NOT EXISTS "${ArrayFire_SOURCE_DIR}/CMakeLists.txt")
set(ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main(int argc, char* argv[]) {

seedx = 15;
seedy = 15;
unsigned seedcoords[]{15, 15};
unsigned seedcoords[] = {15, 15};
array seeds(dim4(1, 2), seedcoords);
array background =
confidenceCC(A, seeds, radius, multiplier, iter, 255);
Expand Down
26 changes: 14 additions & 12 deletions examples/machine_learning/kmeans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ int kmeans_demo(int k, bool console) {
printf("** ArrayFire K-Means Demo (k = %d) **\n\n", k);

array img =
loadImage(ASSETS_DIR "/examples/images/spider.jpg") /
255; // [0-255]
loadImage(ASSETS_DIR "/examples/images/spider.jpg") / 255; // [0-255]

int w = img.dims(0), h = img.dims(1), c = img.dims(2);
array vec = moddims(img, w * h, 1, c);
Expand All @@ -129,23 +128,26 @@ int kmeans_demo(int k, bool console) {
kmeans(means_dbl, clusters_dbl, vec, k * 2);

if (!console) {
array out_full = moddims(means_full(span, clusters_full, span), img.dims());
array out_half = moddims(means_half(span, clusters_half, span), img.dims());
array out_dbl = moddims(means_dbl (span, clusters_dbl , span), img.dims());
array out_full =
moddims(means_full(span, clusters_full, span), img.dims());
array out_half =
moddims(means_half(span, clusters_half, span), img.dims());
array out_dbl =
moddims(means_dbl(span, clusters_dbl, span), img.dims());

af::Window wnd(800, 800, "ArrayFire K-Means Demo");
wnd.grid(2, 2);
std::string out_full_caption = "k = " + std::to_string(k);
std::string out_half_caption = "k = " + std::to_string(k / 2);
std::string out_dbl_caption = "k = " + std::to_string(k * 2);
std::stringstream out_full_caption, out_half_caption, out_dbl_caption;
out_full_caption << "k = " << k;
out_half_caption << "k = " << k / 2;
out_dbl_caption << "k = " << k * 2;
while (!wnd.close()) {
wnd(0, 0).image(img, "Input Image");
wnd(0, 1).image(out_full, out_full_caption.c_str());
wnd(1, 0).image(out_half, out_half_caption.c_str());
wnd(1, 1).image(out_dbl, out_dbl_caption.c_str());
wnd(0, 1).image(out_full, out_full_caption.str().c_str());
wnd(1, 0).image(out_half, out_half_caption.str().c_str());
wnd(1, 1).image(out_dbl, out_dbl_caption.str().c_str());
wnd.show();
}

} else {
means_full =
moddims(means_full, means_full.dims(1), means_full.dims(2));
Expand Down
2 changes: 1 addition & 1 deletion examples/machine_learning/neural_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ std::string toStr(const dtype dt) {
switch(dt) {
case f32: return "f32";
case f16: return "f16";
default: return std::to_string(dt);
default: return "N/A";
}
}

Expand Down