e******r 发帖数: 220 | 1 在科学计算里, 我们一般什么情况用 pointer to pointer(for example double*
*) 传递值?
什么情况下用 pointer (for example double *)来传递值?
| j**u 发帖数: 6059 | 2
double*
这个问题还真难回答。
【在 e******r 的大作中提到】 : 在科学计算里, 我们一般什么情况用 pointer to pointer(for example double* : *) 传递值? : 什么情况下用 pointer (for example double *)来传递值? :
| j**u 发帖数: 6059 | 3 找本C语言的书,看看指针数组那段。
numfactor, double
【在 e******r 的大作中提到】 : 在科学计算里, 我们一般什么情况用 pointer to pointer(for example double* : *) 传递值? : 什么情况下用 pointer (for example double *)来传递值? :
| p*****e 发帖数: 310 | 4 难道不是**用在二维数组,*用在一维吗
numfactor, double
【在 e******r 的大作中提到】 : 在科学计算里, 我们一般什么情况用 pointer to pointer(for example double* : *) 传递值? : 什么情况下用 pointer (for example double *)来传递值? :
| f*******a 发帖数: 80 | 5 For a 2D array, i.e. a matrix, there is advantage to use * but not **,
particularly for very large size.
For large 2D array, there is a need to dynamically allocate memory. If you
want to use **, you will need two malloc statements and a for loop to get
the 2D array ready. Also, you will need another for loop to free the memory
space. The advantage is that you can still use the square brackets, e.g. a[]
[] to index each elements.
If you use *, the advantage is that you only need one malloc state
【在 p*****e 的大作中提到】 : 难道不是**用在二维数组,*用在一维吗 : : numfactor, double
| O******e 发帖数: 734 | 6 Using ** to deal with 2D arrays normally means that the array is not
stored contiguously in memory, and for nonsparse algorithms manipulating
the entire array at once the fragmentation can inhibit code optimization
since the compiler will generally have difficulty resolving aliasing and
flow
dependency issues.
FFTW and other references suggest allocating the entire array using *,
then using ** to point to the beginning of each row if you want the
convenience of using [][] indexing.
memory
[]
th
【在 f*******a 的大作中提到】 : For a 2D array, i.e. a matrix, there is advantage to use * but not **, : particularly for very large size. : For large 2D array, there is a need to dynamically allocate memory. If you : want to use **, you will need two malloc statements and a for loop to get : the 2D array ready. Also, you will need another for loop to free the memory : space. The advantage is that you can still use the square brackets, e.g. a[] : [] to index each elements. : If you use *, the advantage is that you only need one malloc state
|
|