Created
January 28, 2013 22:56
-
-
Save alphaville/4660079 to your computer and use it in GitHub Desktop.
SMDV_QUAD returns x'*Q*x where Q is a sparse matrix and x a vector.
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)); | |
| end | |
| time=toc; | |
| end % end-funct |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment