473,399 Members | 4,192 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.

problems on assigning value to a 3D array and print it out,thx:)

dd
Hi, I have the following code and want to assign value to a 3D arrays
and print it out. But it seems that the value 1 hasn't been assigned to
that array.

Could anyone help me out? Thank you very much!
int ***alloc3d( int dim1, int dim2, int dim3)
{
int i,j;
int ***base=(int ***)malloc(sizeof(int**)*dim1);
for(i=0;i<dim1;i++)
{
base[i]=(int **)malloc(sizeof(int*)*dim2);
for(j=0;j<dim2;j++)
base[i][j]=(int *)malloc(sizeof(int)*dim3);
}
return base;
}

snn.weights=alloc3d(len_delay+1, sum_neurons+1, sum_neurons+1);
for (h=1;h<=len_delay;h++){
neuron_index=1;
for (i=1;i<=snn.num_layers;i++)

for (j=1;j<=snn.neurons_per_layer[i];j++){
for(k=1;k<=snn.neurons_per_layer[i+1];k++){
for (sumtemp=0,temp=0;temp<=i;temp++)
{
sumtemp=sumtemp+snn.neurons_per_layer[temp];
}
snn.weights[h][neuron_index][sumtemp+k]=1;

}
neuron_index=neuron_index+1;
}

void print_SNN(SNN *psnn) {
#ifdef printweights

len_delay=ceil((psnn->delay_range[2]-psnn->delay_range[0])/psnn->delay_range[1]);

for (h=1;h<=len_delay;h++){
for (i=1;i<=psnn->num_layers;i++)
for (j=1;j<=psnn->neurons_per_layer[i];j++){

printf("\n h, %d, i, %d, j, %d, weights %f \n", h,i,j,
psnn->weights[h][i][j]);
}

}
#endif
}

Mar 29 '06 #1
0 1181

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

Similar topics

1
by: Jochen Califice | last post by:
hello ng! got a problem sorting my multi-dimensional array. I have the following situation of an array: $fahrzeugarray= "23" $fahrzeugarray="Audi TT" $fahrzeugarray= "34" $fahrzeugarray="VW...
12
by: Eigenvector | last post by:
I've been dinking around with this code for a while now and I can't seem to figure out where the problem lies. The original problem was that I for some reason or another couldn't allocate few...
5
by: Robert Oschler | last post by:
I am converting a Perl script over to "C" for a potential open source project. I need some open source "C" code that will give me the same functionality of a Perl Style associative array: ...
1
by: Steve Caliendo | last post by:
Hi, How do I set a variable to be null? I want to update a set in a database, and in some cases I would like a particular field to remain unchanged, or null. I'm building a query string based...
2
by: huzzaa | last post by:
I am trying to get the user to input 1-10 and that will select a a number from an array and place it into a variable. here is the code. do { cout << "Enter the first row...
4
jeffbroodwar
by: jeffbroodwar | last post by:
Hello, i have a problem about assigning a char value to a byte... please check the code below : ======================================================== Scenario # 1 : This code doesn't work : ...
1
by: Neil Chambers | last post by:
I'm currently using multidimensional arrays in PoSH by assigning values to index positions. I'm doing this because AFAIK there is no way to initialise an array simply with the 'number' of...
8
by: getmeidea | last post by:
Hi, I am using JDK 1.5. I have a program like this. Here i am directly assigning value to one object. It does'nt give me any compile time or run time error. In java we dont have access to any...
20
by: Shalini Bhalla | last post by:
i am not able to assign values ,can any one tell me whats wrong .... <script> function changeMySrc(nm,act) { alert("hi"+ nm ); if(act == 1) { ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.