utils.h (2014-04-30 15:38:09 -0400, (build fd32605))
Go to the documentation of this file.
1 #ifndef __AF_UTILS__
2 #define __AF_UTILS__
3 #include <stdio.h>
4 #include "array.h"
5 #include "core.h"
6 
7 namespace af {
8 
17  AFAPI void _print(const char* str, const array exp);
18 
35 #define print(exp) _print(#exp, exp)
36 
48  AFAPI void _printdims(const char* str, const array exp);
49 
61 #define printdims(exp) _printdims(#exp, exp)
62 
66 // print the top N values of matrices/vectors
67 #define top(exp) do { _top(#exp, exp); } while (0)
68 
69 AFAPI void _top(const char* exp, array X);
70 
71 // print min and max of array
72 #define stats(exp) _stats(#exp, exp)
73 AFAPI void _stats(const char* exp_str, const array& exp);
74 
75 // print a line on screen using printf syntax.
76 // Usage: Uses same syntax and semantics as printf.
77 // Output: <filename>:<line number>: <message>
78 #ifndef MSG
79 #define _printf_ printf
80 #define MSG(msg,...) do { \
81  _printf_(__FILE__":%d: " msg "\n", \
82  __LINE__, ##__VA_ARGS__); \
83  } while (0)
84 #endif
85 
86 };
87 
88 #endif
array exp(const array &x)
void _top(const char *exp, array X)
void _printdims(const char *str, const array exp)
Display expression and its dimensions.
void _print(const char *str, const array exp)
Display expression and its value.
#define AFAPI
Definition: defines.h:45
void _stats(const char *exp_str, const array &exp)