SQL Server 2008、数值库、c++、LAPACK、内存问题
我正在尝试将 SQL Server 2008 中的数字表发送
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 476 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
到数学库 LAPACK
,例如:通过 Visual Studio 2008(在 C++ 项目中)。
是否可以将 SQL Server 中的表传递给 LAPACK
(通过 Visual Studio 2008 中的 C++)像内存指针,或者将所有表存储在 RAM 中< /strong>,并且 LAPACK 读取内存或指向内存的指针,但不写入文件并读取它
您能否建议如何传递这样的表(可能是表在内存中的位置,或者类似的东西)到 LAPACK?
(所以我可以通过 Visual Studio 2008 C++ 项目使用 SQL Server 中存储的表的 LAPACK 进行一些计算)
----编辑---
@MarkD,正如你在回答中所说的可以请给出一个使用 std::vector 类按照示例中的想法计算 SVD 的示例 ?
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 476 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
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
LAPACK 要求发送给它的数据采用 FORTRAN 样式(列序)数组。您无法将数据直接从 SQL 传递到 LAPACK,但需要将数据读入按列排序的连续内存数组,并将指向数组第一个元素的指针传递给感兴趣的 LAPACK 例程。
有许多 C/C++ 的 LAPACK 包装器可以使这变得更加容易。
编辑:刚刚看到您正在专门寻找如何传递这样的数组。正如我提到的,有许多包装器可以执行此操作(只需搜索 C/C++ LAPACK)。创建数组的一个简单方法是使用 std::vector 类。然后,您将逐列读取数据,将元素添加到向量中 - 因此,如果您想对示例中显示的数组进行列排序,您的向量最终会看起来像这样
:感兴趣的 LAPACK 例程第一个元素的内存位置,例如:
这可以使用 std::vector,因为标准确保向量使用连续的内存存储。 LAPACK 例程还需要您传递给它的矩阵/向量的大小/维数(因此您需要为函数调用计算/指定这些值)。
如果您可以发布您想要使用的特定 LAPACK 例程,我可以给出更全面的示例。
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:
You would then pass the LAPACK routine of interest the memory location of the first element, eg:
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.