This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * File: dataloader_test.c | |
| * Author: imt | |
| * | |
| * Created on Jan 23, 2013, 11:12:09 AM | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <time.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef csi | |
| #define csi ptrdiff_t | |
| #endif | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <stddef.h> | |
| typedef struct cs_sparse { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void doStuff(void) { | |
| // Les data: | |
| float A[4][4] = // the matrix to be multiplied | |
| { | |
| {1.0f, 1.0f, 1.0f, 1.0f}, | |
| {0.0f, 1.0f, 1.0f, 4.0f}, | |
| {1.0f, 1.0f, 1.0f, 4.0f}, | |
| {6.0f, 2.0f, 1.0f, 1.0f} | |
| }; | |
| float a = 0.5f; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stddef.h> | |
| int main(int argc, char** argv) { | |
| float A[4][4] ={ | |
| {1.0f, 2.0f, 3.0f, 4.0f}, | |
| {4.0f, 5.0f, 6.0f, 7.0f}, | |
| {8.0f, 9.0f, 10.0f, 11.0f}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| zreal primal_cost(const cs *Q, const cs *R, const cs *Pf, const ptrdiff_t N, const zmatr* X, const zmatr* U) { | |
| zreal J = 0; | |
| ptrdiff_t k; | |
| zvect* xk = malloc(sizeof(zvect)); | |
| zvect* uk = malloc(sizeof(zvect)); | |
| for (k = 0; k < N; k++) { | |
| *xk = X->values + k; | |
| *uk = U->values + k; | |
| J += dvsm_quad(Q, *xk); | |
| J += dvsm_quad(R, *uk); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [y, time] = smdv_quad(Q,x)%#codegen | |
| %SMDV_QUAD returns x'*Q*x where Q is a sparse matrix and x a vector. | |
| coder.extrinsic('tic'); | |
| coder.extrinsic('toc'); | |
| tic; | |
| y=0; | |
| for k=1:size(Q,1) | |
| i = Q(k,1); | |
| y = y + Q(k,3) * x(i) * x(Q(k,2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % SMDV_QUAD.m | |
| disp('Compiling : SMDV_QUAD'); | |
| mex CFLAGS='$CFLAGS -Wall' -O -output smdv_quad -largeArrayDims mx_smdv_quad.c smdv_quad.c | |
| % PCOST.m | |
| disp('Compiling : PCOST'); | |
| mex CFLAGS='$CFLAGS -Wall' -O -output pcost -largeArrayDims pcost.c smdv_quad.c /usr/lib/libcblas.dylib | |
| mex CFLAGS='$CFLAGS -Wall' -O -output dgrad -largeArrayDims dgrad.c smdv_quad.c vec_util.c /usr/lib/libcblas.dylib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function output = val2worspace(varargin) | |
| % All variables of this function will be exported | |
| % to the workspace | |
| WHO = who; | |
| for i = 1:length(WHO) | |
| assignin('base', WHO{i}, eval(WHO{i})); | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| author: jbenet | |
| os x, compile with: gcc -o testo test.c | |
| linux, compile with: gcc -o testo test.c -lrt | |
| */ | |
| #include <time.h> | |
| #include <sys/time.h> | |
| #include <stdio.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| time_test = 4; % Time each test may last (in seconds) | |
| tic; | |
| t1=0; | |
| ntrials=0; | |
| while (t1<time_test) | |
| % Do things to be benchmarked | |
| ntrials=ntrials+1; | |
| t1=toc; | |
| end |