dynamic-arrays

Declaring a dynamic array not working as expected

[亡魂溺海] 提交于 2019-11-28 14:28:01
RsProxyList.Open objDBCommand,,1,1 dim recCount:recCount = RsProxyList.RecordCount Dim output(recCount,2) I get an error because recCount is of wrong type. I have tried to convert it to Int but that does not work either. The following works fine: RsProxyList.Open objDBCommand,,1,1 dim recCount:recCount = RsProxyList.RecordCount Dim output(3,2) How do I convert recCount to get this array declaration to work? Lankymart You need to first declare your Array as dynamic then use ReDim to set the first dimension dynamically, like this; Dim output() 'Declare a "Dynamic Array" ReDim output(recCount, 2)

What is the status on dynarrays?

狂风中的少年 提交于 2019-11-28 11:28:46
gcc 4.9 now has support for n3696 (Runtime-sized arrays with automatic storage duration) . n3662 says: In N3497 Runtime-sized arrays with automatic storage duration, Jens Maurer proposes arrays with runtime bound. These arrays are to std::dynarray as normal fixed-size arrays are to std::array. In this mailing list , Jonathan Wakely says: We should add a C++14 status table to the manual but in the meantime here's a quick summary of the library status. ... These ones are missing: N3672 A proposal to add a utility class to represent optional objects N3655 TransformationTraits Redux N3662 C++

How Can I Save a Dynamic Array to a FileStream in Delphi?

眉间皱痕 提交于 2019-11-28 10:16:59
I have the following structures in Delphi 2009: type IndiReportIndi = record IndiName: string; NameNum: integer; ReportIndiName: string; end; var XRefList: array of IndiReportIndi; where XRefList is a dynamic array. I want to save XRefList to a FileStream. How do I do that AND include all the IndiName and ReportIndiName strings so that they will all be retrievable again when I later load from that FileStream? Use: http://code.google.com/p/kblib/ type IndiReportIndi = record IndiName: string; NameNum: integer; ReportIndiName: string; end; TXRefList = array of IndiReportIndi; var XRefList:

Why does my pointer output a string and not a memory address in C++? [duplicate]

我与影子孤独终老i 提交于 2019-11-28 05:18:21
问题 This question already has an answer here: cout << with char* argument prints string, not pointer value 6 answers I'm working on a string class that employs pointers and I'm just having some difficulty in understanding how my print function works here. Specifically, why does cout << pString output the string and not the memory address of the dynamic array that it's pointing to? My understanding was that the variable pString was a pointer. class MyString { public: MyString(const char *inString)

NumPy style arrays for C++?

让人想犯罪 __ 提交于 2019-11-28 03:18:50
Are there any C++ (or C) libs that have NumPy-like arrays with support for slicing, vectorized operations, adding and subtracting contents element-by-element, etc.? nojhan Here are several free software that may suit your needs. The GNU Scientific Library is a GPL software written in C. Thus, it has a C-like allocation and way of programming (pointers, etc.). With the GSLwrap , you can have a C++ way of programming, while still using the GSL. GSL has a BLAS implementation, but you can use ATLAS instead of the default CBLAS, if you want even more performances. The boost/uBLAS library is a BSL

Why does my pointer output a string and not a memory address in C++? [duplicate]

匆匆过客 提交于 2019-11-28 01:23:01
This question already has an answer here: cout << with char* argument prints string, not pointer value 6 answers I'm working on a string class that employs pointers and I'm just having some difficulty in understanding how my print function works here. Specifically, why does cout << pString output the string and not the memory address of the dynamic array that it's pointing to? My understanding was that the variable pString was a pointer. class MyString { public: MyString(const char *inString); void print(); private: char *pString; }; MyString::MyString(const char *inString) { pString = new

How to get priorly-unknown array as the output of a function in Fortran

£可爱£侵袭症+ 提交于 2019-11-27 20:12:17
In Python : def select(x): y = [] for e in x: if e!=0: y.append(e) return y that works as: x = [1,0,2,0,0,3] select(x) [1,2,3] to be translated into Fortran : function select(x,n) result(y) implicit none integer:: x(n),n,i,j,y(?) j = 0 do i=1,n if (x(i)/=0) then j = j+1 y(j) = x(i) endif enddo end function The questions are in Fortran: how to declare y(?) ? how to declare predefined values for x how to avoid dimension info n for 1 if it is defined as y(n) the output will be: x = (/1,0,2,0,0,3/) print *,select(x,6) 1,2,3,0,0,0 which is not desired! !------------------------------- Comments: 1-

Fastest way to add an Item to an Array

╄→гoц情女王★ 提交于 2019-11-27 20:07:12
What is the fastest way to add a new item to an existing array? Dim arr As Integer() = {1, 2, 3} Dim newItem As Integer = 4 (I already know that when working with dynamic list of items you should rather use a List , ArrayList or similar IEnumerables . But what to do if you're stuck to legacy code that uses arrays?) What I've tried so far: ' A) converting to List, add item and convert back Dim list As List(Of Integer)(arr) list.Add(newItem) arr = list.ToArray() ' --> duration for adding 100.000 items: 33270 msec ' B) redim array and add item ReDim Preserve arr(arr.Length) arr(arr.Length - 1) =

Why both runtime-sized arrays and std::dynarray in C++14?

安稳与你 提交于 2019-11-27 17:05:40
问题 Draft C++14 includes both runtime-sized arrays and the std::dynarray container. From what I can tell, the only real difference between the two is that std::dynarray has an STL interface (e.g., begin , end , size , etc.), while runtime-sized arrays do not. So why does C++14 need them both? I understand that runtime-sized arrays are part of the core language, while std::dynarray is part of the standard library, but the proposal for std::dynarray makes clear that the authors expect compilers, in

How to declare 2D c-arrays dynamically in Cython

爷,独闯天下 提交于 2019-11-27 16:46:52
问题 I need to perform a lot of work using 2D numpy arrays of various sizes and I would like to offload these calculations onto cython. The idea is that my 2D numpy arrays would be passed from python to cython where it would be converted into c-array or memory view and used in a cascade of other c-level functions to do the calculations. After some profiling I ruled out using numpy arrays in cython due to some serious python overhead. Using memory views was MUCH faster and quite easy to use, but I