Sponsored Content
Full Discussion: matrix pointer
Top Forums Programming matrix pointer Post 302293116 by shamrock on Monday 2nd of March 2009 11:27:45 AM
Old 03-02-2009
Code:
/* creates a pointer named tab that points to an array of MAXCLASS items of type float */
float (*tab)[MAXCLASS];

/* 
  allocates memory for MAXCLASS elements each of size (MAXCLASS+1)*sizeof(float) bytes and
  initializes all memory locations to zeros and casts the pointer to the appropriate type
 */
tab=(float (*)[MAXCLASS]) calloc(MAXCLASS, (MAXCLASS+1)*sizeof(float));

The last one allocates too much memory and IMO the calloc should be...
Code:
/*
  allocates memory for MAXCLASS elements each of sizeof(float) bytes and sets
  the memory locations to zeros and casts the pointer to the appropriate type
 */
tab=(float (*)[MAXCLASS]) calloc(MAXCLASS, sizeof(float));

 

10 More Discussions You Might Find Interesting

1. Programming

pointer

void main() { int a={1,2,3,4,5,6,7,8,9,10}; int *p=a; int *q=&a; cout<<q-p+1<<endl; } The output is 10, how? if we give cout<<q it will print the address, value won't print.... if we give cout<<p it will print the address, value won't print.... p has the base addr; q... (1 Reply)
Discussion started by: sarwan
1 Replies

2. Programming

why we never delete a pointer twice

can u tell me the reson that why we should not delete a pointer twice.? if we delete ponter twice then what happen and why this happen Regards, Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies

3. Programming

far pointer

what is far pointer in C (1 Reply)
Discussion started by: useless79
1 Replies

4. Programming

pass a pointer-to-pointer, or return a pointer?

If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it: (1) one is to pass a pointer-to-pointer parameter, like: int my_malloc(int size, char **pmem) { *pmem=(char *)malloc(size); if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies

5. Shell Programming and Scripting

diagonal matrix to square matrix

Hello, all! I am struggling with a short script to read a diagonal matrix for later retrieval. 1.000 0.234 0.435 0.123 0.012 0.102 0.325 0.412 0.087 0.098 1.000 0.111 0.412 0.115 0.058 0.091 0.190 0.045 0.058 1.000 0.205 0.542 0.335 0.054 0.117 0.203 0.125 1.000 0.587 0.159 0.357... (11 Replies)
Discussion started by: yifangt
11 Replies

6. Programming

pointer conversion in c

hi there fellos could someone teach me how to convert a character pointer into an integer using c much love (1 Reply)
Discussion started by: surubi_abada
1 Replies

7. Ubuntu

How to convert full data matrix to linearised left data matrix?

Hi all, Is there a way to convert full data matrix to linearised left data matrix? e.g full data matrix Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7 Bh1 0 0.241058 0.236129 0.244397 0.237479 0.240767 0.245245 Bh2 0.241058 0 0.240594 0.241931 0.241975 ... (8 Replies)
Discussion started by: evoll
8 Replies

8. Shell Programming and Scripting

awk? adjacency matrix to adjacency list / correlation matrix to list

Hi everyone I am very new at awk but think that that might be the best strategy for this. I have a matrix very similar to a correlation matrix and in practical terms I need to convert it into a list containing the values from the matrix (one value per line) with the first field of the line (row... (5 Replies)
Discussion started by: stonemonkey
5 Replies

9. Programming

pointer problem

Does anyone know? int x = 1; int *p = &++x; //ok ! int *q = &x++; //gives an error :O why the first pointer is ok but the second is an error? (13 Replies)
Discussion started by: nishrestha
13 Replies

10. Programming

Pointer for 2D array seems to be 3D in C

I am struggling with the pointer to 2D-array (cf: 2D array of pointers). Can anybody help me elaborate how the pointer x moves in the memory to access the individual of y, especially the high lighted lines? I have talked to one of the curators of the forum, but I am still not quite clear. Here... (1 Reply)
Discussion started by: yifangt
1 Replies
glu(3erl)						     Erlang Module Definition							 glu(3erl)

NAME
glu - A part of the standard OpenGL Utility api. DESCRIPTION
A part of the standard OpenGL Utility api. See www.opengl.org Booleans are represented by integers 0 and 1. DATA TYPES
clamp() : A float clamped between 0.0 - 1.0 enum() : An integer defined in gl.hrl mem() : memory block offset() : An integer which is an offset in an array EXPORTS
tesselate(X1::Vec3, Vs::[Vec3]) -> {Triangles, VertexPos} Types Vec3 = {float(), float(), float()} Triangles = [VertexIndex::integer()] VertexPos = binary() General purpose polygon triangulation. The first argument is the normal and the second a list of vertex positions. Returned is a list of indecies of the vertices and a binary (64bit native float) containing an array of vertex positions, it starts with the ver- tices in Vs and may contain newly created vertices in the end. build1DMipmapLevels(Target::enum(), InternalFormat::integer(), Width::integer(), Format::enum(), Type::enum(), Level::integer(), Base::integer(), Max::integer(), Data::binary()) -> integer() See external documentation. build1DMipmaps(Target::enum(), InternalFormat::integer(), Width::integer(), Format::enum(), Type::enum(), Data::binary()) -> integer() See external documentation. build2DMipmapLevels(Target::enum(), InternalFormat::integer(), Width::integer(), Height::integer(), Format::enum(), Type::enum(), Level::integer(), Base::integer(), Max::integer(), Data::binary()) -> integer() See external documentation. build2DMipmaps(Target::enum(), InternalFormat::integer(), Width::integer(), Height::integer(), Format::enum(), Type::enum(), Data::binary()) -> integer() See external documentation. build3DMipmapLevels(Target::enum(), InternalFormat::integer(), Width::integer(), Height::integer(), Depth::integer(), Format::enum(), Type::enum(), Level::integer(), Base::integer(), Max::integer(), Data::binary()) -> integer() See external documentation. build3DMipmaps(Target::enum(), InternalFormat::integer(), Width::integer(), Height::integer(), Depth::integer(), Format::enum(), Type::enum(), Data::binary()) -> integer() See external documentation. checkExtension(ExtName::string(), ExtString::string()) -> 0 | 1 See external documentation. cylinder(Quad::integer(), Base::float(), Top::float(), Height::float(), Slices::integer(), Stacks::integer()) -> ok See external documentation. deleteQuadric(Quad::integer()) -> ok See external documentation. disk(Quad::integer(), Inner::float(), Outer::float(), Slices::integer(), Loops::integer()) -> ok See external documentation. errorString(Error::enum()) -> string() See external documentation. getString(Name::enum()) -> string() See external documentation. lookAt(EyeX::float(), EyeY::float(), EyeZ::float(), CenterX::float(), CenterY::float(), CenterZ::float(), UpX::float(), UpY::float(), UpZ::float()) -> ok See external documentation. newQuadric() -> integer() See external documentation. ortho2D(Left::float(), Right::float(), Bottom::float(), Top::float()) -> ok See external documentation. partialDisk(Quad::integer(), Inner::float(), Outer::float(), Slices::integer(), Loops::integer(), Start::float(), Sweep::float()) -> ok See external documentation. perspective(Fovy::float(), Aspect::float(), ZNear::float(), ZFar::float()) -> ok See external documentation. pickMatrix(X::float(), Y::float(), DelX::float(), DelY::float(), Viewport::{integer(), integer(), integer(), integer()}) -> ok See external documentation. project(ObjX::float(), ObjY::float(), ObjZ::float(), Model::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, Proj::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, View::{integer(), integer(), integer(), inte- ger()}) -> {integer(), WinX::float(), WinY::float(), WinZ::float()} See external documentation. quadricDrawStyle(Quad::integer(), Draw::enum()) -> ok See external documentation. quadricNormals(Quad::integer(), Normal::enum()) -> ok See external documentation. quadricOrientation(Quad::integer(), Orientation::enum()) -> ok See external documentation. quadricTexture(Quad::integer(), Texture::0 | 1) -> ok See external documentation. scaleImage(Format::enum(), WIn::integer(), HIn::integer(), TypeIn::enum(), DataIn::binary(), WOut::integer(), HOut::integer(), Type- Out::enum(), DataOut::mem()) -> integer() See external documentation. sphere(Quad::integer(), Radius::float(), Slices::integer(), Stacks::integer()) -> ok See external documentation. unProject(WinX::float(), WinY::float(), WinZ::float(), Model::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, Proj::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, View::{integer(), integer(), integer(), inte- ger()}) -> {integer(), ObjX::float(), ObjY::float(), ObjZ::float()} See external documentation. unProject4(WinX::float(), WinY::float(), WinZ::float(), ClipW::float(), Model::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, Proj::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, View::{integer(), integer(), integer(), integer()}, NearVal::float(), FarVal::float()) -> {integer(), ObjX::float(), ObjY::float(), ObjZ::float(), ObjW::float()} See external documentation. AUTHORS
<> wxErlang 0.98.9 glu(3erl)
All times are GMT -4. The time now is 09:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy