473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

length of array filled with pointers?

I'm writing a little matrix multiplication program, and for the moment, I
have to check if two matrices have the same dimensions. A matrix in my
program is an array of pointers. How can I check if two of those matrices
have the same dimensions, e.g.: 3*3?

Thank you, Thomas
--
Now I'm discovering your magazine, and I want to receive it by
email... The question is > How can I receive the magazine by email???

[ wget http://www.phrack.org/archive/phrack62.tar.gz;
puuencode phrack62.tar.gz p62.tar.gz | mail br**@cimex.com.cu ]
Nov 14 '05 #1
3 1249
Thomas Deschepper wrote:

I'm writing a little matrix multiplication program, and for the moment, I
have to check if two matrices have the same dimensions. A matrix in my
program is an array of pointers. How can I check if two of those matrices
have the same dimensions, e.g.: 3*3?


By making a struct which includes a pointer to this matrix, along with a
height and width. Then, compare the height and width.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Nov 14 '05 #2

"Thomas Deschepper" <th********************@sintjozefscollege.be> wrote

I'm writing a little matrix multiplication program, and for the moment, I
have to check if two matrices have the same dimensions. A matrix in my
program is an array of pointers. How can I check if two of those matrices
have the same dimensions, e.g.: 3*3?

A C pointer is normally implemented as just a bare address. There is
therefore no way of knowing what object a pointer points to, short of
keeping track of this information in the program (the C type system does a
lot of that for you).

What you need to do is declare

typedef struct
{
int width;
int height;
double *values;
} MATRIX;

Then the function is passed two MATRIX *s, and simply checks the width and
height fields.
Nov 14 '05 #3
Thomas Deschepper wrote:
I'm writing a little matrix multiplication program, and for the moment, I
have to check if two matrices have the same dimensions. A matrix in my
program is an array of pointers. How can I check if two of those matrices
have the same dimensions, e.g.: 3*3?

Thank you, Thomas


Thx for the quick replies :)

--
Now I'm discovering your magazine, and I want to receive it by
email... The question is > How can I receive the magazine by email???

[ wget http://www.phrack.org/archive/phrack62.tar.gz;
puuencode phrack62.tar.gz p62.tar.gz | mail br**@cimex.com.cu ]
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: F Da Costa | last post by:
Hi, Small question re the use of an Array. I'v got an array with x rowObjects in it. When i get it the type of the container is Array and i can get a hold of the objects just fine. owever,...
10
by: Adam Warner | last post by:
Hi all, With this structure that records the length of an array of pointers as its first member: struct array { ptrdiff_t length; void *ptr; };
12
by: natkw1 | last post by:
Hi, I'm attempting to understand the use of pointers(at least grasp how pointers work). I've read the FAQ on http://www.eskimo.com/~scs/C-faq/s6.html on pointers and arrays but I'm still a bit...
0
by: Brian Black | last post by:
Hi, Sorry For the Cross Posting But, I just started programming .net and i have a question. I have a byte array of 14 bytes (CODE BELOW), i need to copy the data from the the byte array into...
3
by: David Mathog | last post by:
This one is driving me slightly batty. The code in question is buried deep in somebody else's massive package but it boils down to this, two pointers are declared, the first is: char **resname...
3
by: Madhu | last post by:
I would like to know how the following will be handled in the .net framework: Pl. don't pay attention to the syntax int a int b a=2 a=2 a=2
14
by: Richard Maher | last post by:
Hi, Can anyone please show me a regular expression (or function or other) for padding out a string to a fixed number of bytes? At the moment I've got a var initialized to N spaces, where 'N'...
2
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
vs 2005 c# How do I get the number of filled item from an array? string myArr = {"","","",""}; myArr = "one"; myArr.Length = 4; How do I get the number of filled item from an array in this...
8
by: Andrew Smallshaw | last post by:
I'm working on a data structure that began life as a skip list derivative, but has evolved to the point that it now only has a passing resemblance to them. Each node of this structure has a few...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.