开发者

SQL Server 2008, numeric library, c++, LAPACK, memory question

I am trying to send a table of numbers in SQL Server 2008 like:

1att 2att 3att 4att 5att 6att 7att ... attn
--------------------------------------------
565  526  472  527  483  529  476  470  502
497  491  483  488  488  483  496  515  491
467  516  480  477  494  497  478  519  471
488  466  547  498  477  466  475  480  516
543  491  449  485  495  468  452  479  516
473  475  431  474  460  342  471  386  549
489  477  462  428  489  491  481  483  475
485  474  472  452  525  508  459  561  529
473  457  476  498  485  465  540  475  525
455  477  415  434  475  499  476  482  551
463  476  476  471  488  526  394  439  475
479  473  491  519  483  474  476  474  478
455  518  465  445  496  500  518  470  536
557  498  492  449  478  491  492  476  460
484  509  538  473  548  497  551  477  498
471  430  482  437  516  483  487  453  456
505  47开发者_如何学Python6  489  495  472  476  487  516  466
466  495  488  475  550  565  510  473  515
470  490  480  475  479  544  468  486  496
484  495  524  435  469  612  493  467  477
....
....  (several more rows)
....
511  471  529  553  539  501  477  474  494

via visual studio 2008 (in a c++ project) to a mathematical library LAPACK.

Is it possible to pass the table in SQL Server to LAPACK (via c++ in visual studio 2008) like a memory pointer, or store all the table in RAM, and LAPACK read memory or pointer to memory, but without writing to a file and reading it

Could you please suggest how to pass a table like this (maybe the location of table in memory, or something similar) to LAPACK?

(so I am able to do some computing with LAPACK of the table stored in SQL Server via visual studio 2008 c++ project)

----EDIT---

@MarkD, As you said in your anwer could you please give an example of computing SVD with the idea in the example, using std::vector class ?


LAPACK requires the data sent to it, to be in a FORTRAN style (Column-order) array. You won't be able to pass the data directly from SQL to LAPACK but will need to read the data into a column-ordered contiguous memory array, and pass a pointer to the first element of the array to the LAPACK routine of interest.

There are many LAPACK wrappers for C/C++ out there that make this much easier.

Edit: just saw you are looking specifically for how to pass such an array. As I mentioned, there are many wrappers out there for doing this (just do a search for C/C++ LAPACK). An easy way to create your array is to use the std::vector class. You would then read the data in, column-by-column, adding the elements to your vector- So if you wanted to column-order the array you show in your exmaple, your vector would end up looking something like:

//Column 1            Column 2            Column 3          ...   last element 
 [565 497 467 488 ... 526 491 516 466 ... 472 483 480 547 ... ... 494]

You would then pass the LAPACK routine of interest the memory location of the first element, eg:

&myVector[0]

This is possible using std::vector, as the standard ensures that a vector uses contiguous memory storage. The LAPACK routines all also require the size/dimensions of the matrix/vectors you are passing to it (so you'll need to calculate/specify these values for the function call).

If you can post the specific LAPACK routine you want to use, I can give a more thorough example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜