multidimensional

Three dimensional arrays of integers in C++

Hi, I would like to find out safe ways of implementing three dimensional arrays of integers in C++, using pointer arithmetic / dynamic memory allocation, or, alternatively using STL techniques such as vectors. Essentially I want my integer array dimensions to look like: [ x ][ y ][ z ] x and y are in the range 20-6000 z is known and ...

Computationally efficient three dimensional arrays in C

I am trying to solve numerically a set of partial differential equations in three dimensions. In each of the equations the next value of the unknown in a point depends on the current value of each unknown in the closest points. To write an efficient code I need to keep the points close in the three dimensions close in the (one-dimension...

How do I sort a multidimensional array in php

I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file. function f_parse_csv($file, $longest, $delimiter) { $mdarray = array(); $file = fopen($file, "r"); while ($line = fgetcsv($file, $longe...

Traversing a multi-dimensional hash in Perl

If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have $f->{$x}{$y}, I want something like foreach ($x, $y) (deep_keys %{$f}) { } instead of foreach $x (keys %f) { foreach $y (keys %{$f->{$x}) { } ...

Slicing a multi-dimensional PHP array across one of its elements.

Say for example you just queried a database and you recieved this 2D array. $results = array( array('id' => 1, 'name' => 'red' , 'spin' => 1), array('id' => 2, 'name' => 'green', 'spin' => -1), array('id' => 3, 'name' => 'blue' , 'spin' => .5) ); I often find myself writing loops like this. foreach($results as $result) ...

How do I create a string from one row of a two dimensional rectangular character array in C#?

I have a 2 dimensional array, like so: char[,] str = new char[2,50]; Now, after I've stored contents in both str[0] and str[1], how do I store it in a string[] s = new string[2]; ? I tried s[0] = str[0].ToString(); but that seems to be an error: VC# expects 'two' indices within the braces, which means I can convert only a cha...

Best way to represent a 2-D array in C++ with size determined at run time

In C++ I'd like to do something like: int n = get_int_from_user(); char* matrix = new char[n][n]; matrix[0][0] = 'c'; //... matrix[n][n] = 'a'; delete [][] matrix; but of course this doesn't work. What is the best way to do something similar? I've seen some solutions to this but they seem pretty messy. ...

How can I create multidimensional arrays in Perl?

Hello, I am a bit new to Perl, but here is what I want to do: my @array2d; while(<FILE>){ push(@array2d[$i], $_); } It doesn't compile since @array2d[$i] is not an array but a scalar value. How sould I declare @array2d as an array of array? Of course, I have no idea of how many rows I have. ...

How do you link two arrays?

I'm in a basic programming class, and everything is done in pseudo code. My question is this: How do you link two arrays? I have a single-dimensional array that lists students names, and I have a two-dimensional array that lists the top eight scores of each student...this is all fine and dandy, but now I need to sort the arrays by th...

How do I best handle dynamic multi-dimensional arrays in C/C++?

What is the accepted/most commonly used way to manipulate dynamic (with all dimensions not known until runtime) multi-dimensional arrays in C and/or C++. I'm trying to find the cleanest way to accomplish what this Java code does: public static void main(String[] args){ Scanner sc=new Scanner(System.in); int rows=sc.nextInt(); int co...

PHP - Iterating multiple $_post arrays

Hi all, I have the following code: <tr> <td width="60%"><dl> <dt>Full Name</dt> <dd> <input name="fullname[]" type="text" class="txt w90" id="fullname[]" value="<?php echo $value; ?>" /> </dd> </dl></td> <td width="30%"><dl> <dt>Job Title</dt> <dd>...

Setting up Dim and Fact tables for a Data Warehouse

I'm tasked with creating a datawarehouse for a client. The tables involved don't really follow the traditional examples out there (product/orders), so I need some help getting started. The client is essentially a processing center for cases (similar to a legal case). Each day, new cases are entered into the DB under the "cases" table....

Fact/Dim Table Time Value

I'm setting up Fact and Dim tables and trying to figure out the best way to setup my time values. AdventureworksDW uses a timekey (UID) for each time entry in the DimTime table. I'm wondering there's any reason I shouldn't just use a time value instead i.e. 0106090800 (My granularity is hourly)? ...

How to design this method if it returns multi-dimensional arrays?

I am now designing an SNMP library. The problem is caused by a special function like this, *** GetTable(string id) This function may return Variable[,] which is a two dimensional array sometimes, but also Variable[,,] and arrays with more dimensions. So I believe it is not reasonable to return fixed array such as Variable[,], Variable[...

double dimensional array value from php

Dear All I have a PHP file going to write a two-dimensional array in javascript: <?php print "<script language='javascript'>"; print " extra[0][0]=new Array(1,'Bob',12);"; print " extra[0][1]=new Array(2,'Alice',18);"; .. // need to assign the extra[1][0],extra[1][1] so on. print "</script>"; ...

C - Pass by reference multidimensional array with known size

In main: char *myData[500][9]; //dynamic rows?? char **tableData[500]={NULL}; //dynamic rows?? int r; newCallBack(db, &myData, &tableData, &r); and passing into function by: void newCallBack(sqlite3 *db, char** mdat, char*** tdat, int* r ) { Doesn't seem to like this? Any suggestions? Lots of examples online when you don...

How do I make a pointer to a multidimensional array which has an unknown size?

how do I make a pointer to a multidimensional array, which have a unknown size? I've tried this: int **triangles; triangles = new int[numTriangles][3]; But i get this error: cannot convert 'int (*)[3]' to 'int**' in assignment ...

C++ Passing a dynamicly allocated 2D array by reference

This question builds off of a previously asked question: Pass by reference multidimensional array with known size I have been trying to figure out how to get my functions to play nicely with 2d array references. A simplified version of my code is: unsigned int ** initialize_BMP_array(int height, int width) { unsigned in...

Passing a variable of type int[5][5] to a function that requires int**

I'd like to test a function that takes runtime-allocated multidimensional arrays, by passing it a hardcoded array. The function has a signature of void generate_all_paths(int** maze, int size) and the array is defined as int arr[5][5] = {REMOVED}. I'm not exactly sure how to properly coerce the array for the function (or if that is imp...

How can I return coordinates/indexes of a string in a multidimensional array? [ruby]

I've got a multidimensional array: foo = [["a","b","c"], ["d", "e", "f"], ["g", "h", "i"]] Now I need to ruturn the "coordinates" of "f", which should be (1,2). How can I do this without knowing which "row" "f" is in? I've been trying to use the index method, but this only works when I tell it where to look, i.e. foo[1].index("f") #...