1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <arrayfire.h>
#include <cstdio>
#include <cstdlib>
using namespace af;
int main(int argc, char *argv[])
{
try {
// Select a device and display arrayfire info
int device = argc > 1 ? atoi(argv[1]) : 0;
af::setDevice(device);
af::info();
array in = randu(5, 8);
af_print(in);
array lin = in.copy();
printf("Running LU InPlace\n");
array pivot;
luInPlace(pivot, lin);
af_print(lin);
af_print(pivot);
printf("Running LU with Upper Lower Factorization\n");
array lower, upper;
lu(lower, upper, pivot, in);
af_print(lower);
af_print(upper);
af_print(pivot);
} catch (af::exception& e) {
fprintf(stderr, "%s\n", e.what());
throw;
}
return 0;
}
|