Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,525 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,205 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



SLICING IN A PROGRAMMING LANGUAGE

 
Reply to this topicStart new topic

SLICING IN A PROGRAMMING LANGUAGE

2+2=5
post 1 May, 2008 - 08:11 AM
Post #1


New D.I.C Head

*
Joined: 1 May, 2008
Posts: 1

HI

how do i implement slicing on a 3-d array( in a languagewhich of course does not support slicing). As in, how do i use the input parameters to get to the slice.
For instance if i have a function 'slice' defined as :
slice(row,column,depth)
how do i use the combination of row,column and depth to figure out my slice-In Fortran 95 for example, doing something like Cube(2,:,:,) would give me the whole of the second layer of a 3 by 3 by 4 array.
User is offlineProfile CardPM

Go to the top of the page


perfectly.insane
post 4 May, 2008 - 02:09 PM
Post #2


D.I.C Addict

Group Icon
Joined: 22 Mar, 2008
Posts: 515



Thanked 38 times
My Contributions


Usually, slicing implies making a copy of the data, so your slice function would need to allocate an array of the specified size, and then copy the specified data to it. How you would do it for a 3-D array depends on how you want to implement the 3-D array itself. If you have three dimensions, then the most obvious way would be to have three nested for loops to copy the data based upon the input parameters.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 08:20PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month