Search Results

Search found 15239 results on 610 pages for 'array population'.

Page 97/610 | < Previous Page | 93 94 95 96 97 98 99 100 101 102 103 104  | Next Page >

  • Array subscript is not an integer

    - by Dimitri
    Hello folks, following this previous question Malloc Memory Corruption in C, now i have another problem. I have the same code. Now I am trying to multiply the values contained in the arrays A * vc and store in res. Then A is set to zero and i do a second multiplication with res and vc and i store the values in A. (A and Q are square matrices and mc and vc are N lines two columns matrices or arrays). Here is my code : int jacobi_gpu(double A[], double Q[], double tol, long int dim){ int nrot, p, q, k, tid; double c, s; double *mc, *vc, *res; int i,kc; double vc1, vc2; mc = (double *)malloc(2 * dim * sizeof(double)); vc = (double *)malloc(2 * dim * sizeof(double)); vc = (double *)malloc(dim * dim * sizeof(double)); if( mc == NULL || vc == NULL){ fprintf(stderr, "pb allocation matricre\n"); exit(1); } nrot = 0; for(k = 0; k < dim - 1; k++){ eye(mc, dim); eye(vc, dim); for(tid = 0; tid < floor(dim /2); tid++){ p = (tid + k)%(dim - 1); if(tid != 0) q = (dim - tid + k - 1)%(dim - 1); else q = dim - 1; printf("p = %d | q = %d\n", p, q); if(fabs(A[p + q*dim]) > tol){ nrot++; symschur2(A, dim, p, q, &c, &s); mc[2*tid] = p; vc[2 * tid] = c; mc[2*tid + 1] = q; vc[2*tid + 1] = -s; mc[2*tid + 2*(dim - 2*tid) - 2] = p; vc[2*tid + 2*(dim - 2*tid) - 2 ] = s; mc[2*tid + 2*(dim - 2*tid) - 1] = q; vc[2 * tid + 2*(dim - 2*tid) - 1 ] = c; } } for( i = 0; i< dim; i++){ for(kc=0; kc < dim; kc++){ if( kc < floor(dim/2)) { vc1 = vc[2*kc + i*dim]; vc2 = vc[2*kc + 2*(dim - 2*kc) - 2]; }else { vc1 = vc[2*kc+1 + i*dim]; vc2 = vc[2*kc - 2*(dim - 2*kc) - 1]; } res[kc + i*dim] = A[mc[2*kc] + i*dim]*vc1 + A[mc[2*kc + 1] + i*dim]*vc2; } } zero(A, dim); for( i = 0; i< dim; i++){ for(kc=0; kc < dim; k++){ if( k < floor(dim/2)){ vc1 = vc[2*kc + i*dim]; vc2 = vc[2*kc + 2*(dim - 2*kc) - 2]; }else { vc1 = vc[2*kc+1 + i*dim]; vc2 = vc[2*kc - 2*(dim - 2*kc) - 1]; } A[kc + i*dim] = res[mc[2*kc] + i*dim]*vc1 + res[mc[2*kc + 1] + i*dim]*vc2; } } affiche(mc,dim,2,"Matrice creuse"); affiche(vc,dim,2,"Valeur creuse"); } free(mc); free(vc); free(res); return nrot; } When i try to compile, i have this error : jacobi_gpu.c: In function ‘jacobi_gpu’: jacobi_gpu.c:103: error: array subscript is not an integer jacobi_gpu.c:103: error: array subscript is not an integer jacobi_gpu.c:118: error: array subscript is not an integer jacobi_gpu.c:118: error: array subscript is not an integer make: *** [jacobi_gpu.o] Erreur 1 The corresponding lines are where I store the results in res and A : res[kc + i*dim] = A[mc[2*kc] + i*dim]*vc1 + A[mc[2*kc + 1] + i*dim]*vc2; and A[kc + i*dim] = res[mc[2*kc] + i*dim]*vc1 + res[mc[2*kc + 1] + i*dim]*vc2; Can someone explain me what is this error and how can i correct it? Thanks for your help. ;)

    Read the article

  • Algorithm to split an array into N groups based on item index (should be something simple)

    - by serg
    I feel that it should be something very simple and obvious but just stuck on this for the last half an hour and can't move on. All I need is to split an array of elements into N groups based on element index. For example we have an array of 30 elements [e1,e2,...e30], that has to be divided into N=3 groups like this: group1: [e1, ..., e10] group2: [e11, ..., e20] group3: [e21, ..., e30] I came up with nasty mess like this for N=3 (pseudo language, I left multiplication on 0 and 1 just for clarification): for(i=0;i<array_size;i++) { if(i>=0*(array_size/3) && i<1*(array_size/3) { print "group1"; } else if(i>=1*(array_size/3) && i<2*(array_size/3) { print "group2"; } else if(i>=2*(array_size/3) && i<3*(array_size/3) print "group3"; } } But what would be the proper general solution? Thanks.

    Read the article

  • SED, using variables and in with an array

    - by S1syphus
    What I am trying to do is run the sed on multiple files in the directory Server_Upload, using variables: AB${count} Corresponds, to some variables I made that look like: echo " AB1 = 2010-10-09Three " echo " AB2 = 2009-3-09Foo " echo " AB3 = Bar " And these correspond to each line which contains a word in master.ta, that needs changing in all the text files in Server_Upload. If you get what I mean... great, I have tried to explain it the best I can, but if you are still miffed I'll give it another go as I found it really hard to convey what I mean. cd Server_Upload for fl in *.UP; do mv $fl $fl.old done count=1 saveIFS="$IFS" IFS=$'\n' array=($(<master.ta)) IFS="$saveIFS" for i in "${array[@]}" do sed "s/$i/AB${count}/g" $fl.old > $fl (( count++ )) done It runs, doesn't give me any errors, but it doesn't do what I want, so any ideas?

    Read the article

  • JavaScript Array Problem

    - by JasonS
    Hi, This wasn't the question I was going to ask but I have unexpectedly run aground with JavaScript arrays. I come from a PHP background and after looking at a few websites I am none the wiser. I am trying to create a multi-dimensional array. var photos = new Array; var a = 0; $("#photos img").each(function(i) { photos[a]["url"] = this.src; photos[a]["caption"] = this.alt; photos[a]["background"] = this.css('background-color'); a++; }); Error message: photos[a] is undefined. How do I do this. Thanks.

    Read the article

  • Appending Integer array elements in Java

    - by Neville
    I have an array, say int a[]={2,0,1,0,1,1,0,2,1,1,1,0,1,0,1}; I need to append each of the 5 neighboring elements and assign them to a new array b with length=(a.length/5); and i want to append the 5 neighboring elements so that I have: int b[]={20101,10211,10101}; I need to do this for various length arrays, in most cases with length of a being greater than 15. Any help would be greatly appreciated, I'm programming in Java. Thanks in advance.

    Read the article

  • Viewing array of pointers to structures in Visual Studio in the debugger

    - by Fozi
    I'm having a problem displaying the contents of a pointer array with its contents in the debugger. If I just add the pointer to the watch only the fist entry is visible. But if I add the length to it the debugger assumes that I have something like array[length][length]. Picture The first entry is the broken one, looks the same with ,2 or with any ,2 x. The second one is what I would like to see, but for more entries. Edit: The two entries displayed as [x][1] are invalid. I'm using VS 2005 but I think I had this problem on 2008 as well. Is this a bug or am I doing something wrong?

    Read the article

  • Display array values from web service method

    - by chupinette
    Hello all! I'm new to web services and im actually trying to learn how to develop one in C#. I have the following method in my web service which actually displays an array of int when i test it. [WebMethod] public int[] FindID(string str1,string str2) { Customer obj = new Customer(); obj.FindMatch(str1,str2); return obj.customer_id; } Now in my web application in which i have a button, the code is as below: Dim obj As localhost.Service = New localhost.Service Dim str1 As String = Session("str1") Dim str2 As String = Session("str2") Response.Write(obj.FindID(str1, str2)) The problem is that only the first value from the array is being displayed. Can anyone please help me to solve this problem?

    Read the article

  • FF extension: displaying an array of string elements in a sidebar

    - by sujay-jain
    I am developing a ff extension which displays a list of elements from an array (dynamic) in the sidebar. The array is dynamic and needs to be constructed in a function everytime the sidebar is opened (or any other event handler). Later, i will need to implement link functionality on parts of the string. What is the best way to go about this? I have created an empty sidebar and just know the label element as of now. menu, and menuitem dont work. What other elements can i use to display text in a good way which supports dynamic contruction. Is there some good tutorial/sample extension which i can see and learn?

    Read the article

  • Generating an array of functions?

    - by Wordpressor
    I have a few PHP files filled with multiple functions. Let's call them functions1.php, functions2.php, functions3.php: function function_something( $atts ) { extract( something_atts( array( 'foo' => 'bar', 'bar' => 'foo, ), $atts ) ); return 'something'; } I'm loading these files within all_functions.php like this: require_once('functions1.php'); require_once('functions2.php'); require_once('functions3.php'); I'm wondering if it's possible to create an array of all these functions and their attributes? I'm thinking about something like: function my_functions() { require_once('functions1.php'); require_once('functions2.php'); require_once('functions3.php'); } And then some foreach loop, but I'm not sure how should it look like after all. I know this probably looks tricky, but I'm just curious if I'm able to list all my WordPress shortcodes without PHP's Reflection API :)

    Read the article

  • JSON ARRAY and JSF

    - by Debbech
    Hi, Im working with JSF and EXT js. I have a JSONArray created in the server-side and I want to pass it to client-side. I used to get the array and put it in javascript var. but this tag adds a html tag (span) which make an error in javascript var ! this is the code I wrote : var data1 = <h:outputFormat value="#{actorBean.newactors}" /> and this is the code of my page after running : var data1 =<span>[[&quot;aaaaaaa&quot;,&quot;bbbbbbb&quot;]]</span> so do u have any idea how to get the array without all the tags added ? thanks

    Read the article

  • Return highest number found in an array of strings

    - by Mdd
    I have an array of objects. The objects have a property called level that is a string which contains a number and is in consistent format. I am trying to find the highest number and return just that one but I seem to be blocked as far as how to proceed from my current code. Here is a fiddle to my current code: http://jsfiddle.net/6sXYR/ Here is my JavaScript: var myArray = [ { color: 'blue', level: 'L1' }, { color: 'red', level: 'L1' }, { color: 'green', level: 'L2' }, { color: 'yellow', level: 'L2' }, { color: 'purple', level: 'L3' } ]; for (var i = 0; i < myArray.length; i++) { console.log( myArray[i].level.substring(1,2) ); }; The result I am trying to get is to return just the number '3' from the example above. The highest number may not always be in the last object in the array, but it will always be in the format of L#.

    Read the article

  • Get Specific Data From Array, Based On Another Value

    - by A Smith
    I have an array that outputs these values: Array ( [0] => stdClass Object ( [ID] => 6585 [COLOR] => red [Name] => steve ) [1] => stdClass Object ( [ID] => 5476 [COLOR] => blue [Name] => sol ) [2] => stdClass Object ( [ID] => 7564 [COLOR] => yellow [Name] => jake ) [3] => stdClass Object ( [ID] => 3465 [COLOR] => green [Name] => helen ) ) Now, I will know the ID of the person, and I need the get the COLOR value for that specific value set. How is this best achieved please?

    Read the article

  • convert string data array to list

    - by prince23
    hi, i have an string data array which contains data like this 5~kiran 2~ram 1~arun 6~rohan now a method returns an value like string [] data public string [] names() { return data.Toarray() } public class Person { public string Name { get; set; } public int Age { get; set; } } List persons = new List(); string [] names =names(); now i need to copy all the data from an string array to an list and finally bind to grid view gridview.datasoutrce= persons how can i do it. is there any built in method to do it thanks in advance prince

    Read the article

  • [iPhone] How to order an array

    - by Fabrizio
    Hi all, I got an array in my app and I need to order by one of its key. Basically what the app does is taking latitude and longitude somewhere, calculate the distance from my actual position and create an array containing a key called "distance". I'm using myArray sortUsingDescriptors: [NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"distance" ascending:YES] autorelease]]]; I'm not sure it's working, I mean the first results are ordered but then it shows distance closer to the previous, as example: 0.8 km 1.6 km 1.9 km 10053.9 km 1098.0 km 2372.0 km 470.5 km Any suggestion? I thank you in advance for any kind of help. Fabrizio

    Read the article

  • C/C++ enum and char * array

    - by Eric M
    Ran accross the following code in an article and didn't think it was standard C/C++ syntax for the char* array. As a test, both Visual C++ (visual studio 2005) and C++ Builder Rad XE both reject the 2nd line. Without using #defines, anyone have any tricks/tips for keeping enums and a string array sort of in sync without resorting to STL ? More of a curiosity question. enum TCOLOR { RED, GREEN, BLUE }; char *TNCOLOR[] = { [RED]="Red", [GREEN]="Green", [BLUE]="Blue" }; as an aside, the article this came from is quite old and I believe this might work under GCC but have not tested.

    Read the article

  • sort array with special characters in php

    - by Enkay
    I have an array I'm trying to asort using php. The problem is that the array has accented characters in it and needs to be sorted using "french" rules. cote < côte < coté < côté I've tried many things, like using php collators, but I get the following error : PHP Fatal error: Class 'Collator' not found I've also tried to set locale but it didn't do anything so I'm not sure I was doing it right, or if I need to isntall the locale. I'm a little confused. I'm using PHP 5.2.4 if that helps. If I use asort without anything, it puts all the words with accented characters at the end. Thanks.

    Read the article

  • Java HashMap with Int Array

    - by Sunil
    Hello I am using this code to check that array is present in the HashMap. public class Test { public static void main(String[]arg) { HashMap<int[],String> map= new HashMap<int[],String>(); map.put(new int[]{1,2}, "sun"); System.out.println(map.containsKey((new int[]{1,2}))); } } But this prints False. How can I check that array is present in the HashMap. Thanks in advance.

    Read the article

  • How to load array values into tableview in iphone app using phonegap

    - by user1586650
    Am new to phonegap. Now am using phonegap2.0 in my Lion mac. My xcode version is 4.3. Now i created Tableview for iphone app using html. And i created array with some values using JavaScript. Please see this below link: In this below link i have attach my html file and my Javascript file. "http://pastie.org/4779045" Now i want to load the array values in tableview. Please some body help me to load done this issue.

    Read the article

  • Printing elements of array using ERB

    - by Keva161
    I'm trying to print a simple array defined in my controller into my view with a new line for each element. But what it's doing is printing the whole array on one line. Here's my controller: class TodosController < ApplicationController def index @todo_array = [ "Buy Milk", "Buy Soap", "Pay bill", "Draw Money" ] end end Here's my view: <%= @todo_array.each do |t| %> <%= puts t %><\br> <% end %> Here's the result: <\br> <\br> <\br> <\br> ["Buy Milk", "Buy Soap", "Pay bill", "Draw Money"]

    Read the article

  • Passing a 2D array to a function in C

    - by Tyler Treat
    I have, essentially, a matrix of data (lets say ints) that I would like to store in a 2D array in which the dimensions are not known until runtime (say x columns and y rows). I want to populate the array in a function, so I assume I need to do something like this: int main(int argc, char **argv) { int y = atoi(argv[1]); int x = atoi(argv[2]); int **matrix = malloc(x * sizeof(int*)); populateMatrix(matrix, y, x); return 0; } void populateMatrix(**matrix, int y, int x) { int i, j; for (i = 0; i < y; i++) { for (j = 0; j < x; j++) { matrix[i][j] = i * j; // populated with trivial data to keep it simple } } } Obviously this doesn't work, but I'm not sure how to do what I'm describing exactly.

    Read the article

  • get renamed file names of multiple upload form [js array] in codeigniter

    - by artmania
    Hi friends, I use codeigniter. I have a multiple image upload form. The code below is working well for uploading, but I also need to save file names to database. How can I get the names in here? I spent hours & hours :/ but could not sort it :/ Appreciate helps!!! uploadform.php echo form_open_multipart('gallery/upload'); <input type="file" name="photo" size="50" /> <input type="file" name="thumb" size="50" /> <input type="submit" value="Upload" /> </form> I have a controller between form view and model load model (of course : )) but didnt post here because of no need. gallery_model.php function multiple_upload($upload_dir = 'uploads/', $config = array()) { /* Upload */ $CI =& get_instance(); $files = array(); if(empty($config)) { $config['upload_path'] = realpath($upload_dir); $config['allowed_types'] = 'gif|jpg|jpeg|jpe|png'; $config['max_size'] = '2048'; } $CI->load->library('upload', $config); $errors = FALSE; foreach($_FILES as $key => $value) { if( ! empty($value['name'])) { if( ! $CI->upload->do_upload($key)) { $data['upload_message'] = $CI->upload->display_errors(ERR_OPEN, ERR_CLOSE); // ERR_OPEN and ERR_CLOSE are error delimiters defined in a config file $CI->load->vars($data); $errors = TRUE; } else { // Build a file array from all uploaded files $files[] = $CI->upload->data(); } } } // There was errors, we have to delete the uploaded files if($errors) { foreach($files as $key => $file) { @unlink($file['full_path']); } } elseif(empty($files) AND empty($data['upload_message'])) { $CI->lang->load('upload'); $data['upload_message'] = ERR_OPEN.$CI->lang->line('upload_no_file_selected').ERR_CLOSE; $CI->load->vars($data); } else { return $files; } /* ------------------------------- Insert to database */ // problem is here, i need file names to add db. // if there is already same names file at the folder, it rename file itself. so in such case, I need renamed file name :/ } }

    Read the article

  • Jquery Ajax Returned Array - how to handle in Javascript

    - by user232840
    Hi there, If someone could assist me please. I'm doing a jquery Ajax post, for some reason the Json object isn't working so just returning a php array instead $.post ( "classes/RegisterUser.php", $("#frmRegistration").serialize(), function(data) { alert(data); } ); The data is returned to Javascript 100% as array ( [key]=>value [Name] => SomeOneName [Surname] => SomeOneSurName ) How would i go about getting the value of Surname in Javascript? Thanks for your assistance? Regards

    Read the article

  • Powershell function that creates a array by input

    - by user2971548
    I'm quite new to Powershell and working on a little project with functions. What I'm trying to do is creating a function that takes 2 arguments. The first argument ($Item1) decides the size of the array, the second argument ($Item2) decides the value of the indexes. So if I write: $addToArray 10 5 I need the function to create a array with 10 indexes and the value 5 in each of them. The second argument would also have to take "text" as a value. This is my code so far. $testArray = @(); $indexSize = 0; function addToArray($Item1, $Item2) { while ($indexSize -ne $Item1) { $indexSize ++; } Write-host "###"; while ($Item2 -ne $indexSize) { $script:testArray += $Item2; $Item2 ++; } } Any help is appreciated. Kind regards Dennis Berntsson

    Read the article

< Previous Page | 93 94 95 96 97 98 99 100 101 102 103 104  | Next Page >