Search Results

Search found 11238 results on 450 pages for 'miserable variable'.

Page 25/450 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • CUDA Kernel Not Updating Global Variable

    - by Taher Khokhawala
    I am facing the following problem in a CUDA kernel. There is an array "cu_fx" in global memory. Each thread has a unique identifier jj and a local loop variable ii and a local float variable temp. Following code is not working. It is not at all changing cu_fx[jj]. At the end of loop cu_fx[jj] remains 0. ii = 0; cu_fx[jj] = 0; while(ii < l) { if(cu_y[ii] > 0) cu_fx[jj] += (cu_mu[ii]*cu_Kernel[(jj-start_row)*Kernel_w + ii]); else cu_fx[jj] -= (cu_mu[ii]*cu_Kernel[(jj-start_row)*Kernel_w + ii]); ii++; } But when I rewrite it using a temporary variable temp, it works fine. ii = 0; temp = 0; while(ii < l) { if(cu_y[ii] > 0) temp += (cu_mu[ii]*cu_Kernel[(jj-start_row)*Kernel_w + ii]); else temp -= (cu_mu[ii]*cu_Kernel[(jj-start_row)*Kernel_w + ii]); ii++; } cu_fx[jj] = temp; Can somebody please help with this problem. Thanking in advance.

    Read the article

  • jquery: set variable based on one class from an element that has more than one class

    - by John
    Hi I'm trying to make a table who's columns and rows highlight on hover (I realise there are jquery plugins out there that will do this, but I'm trying to learn, so thought I'd have a stab at doing it for myself.) Here's what I've got so far: $('th:not(.features), td:not(.features)').hover(highlight); function highlight(){ $('th.highlightCol, td.highlightCol').removeClass('highlightCol'); var col = $(this).attr('class'); $('.' + col).addClass('highlightCol'); }; $('tr').hover(highlightRowOn, highlightRowOff); function highlightRowOn(){ $(this).children('td:not(.highlightCol)').addClass('highlightRow'); }; function highlightRowOff(){ $(this).children('td:not(.highlightCol)').removeClass('highlightRow'); }; This works fine apart from one problem: Each 'td' has a class specific to it's column (package1, package2, package3, package4). It is this that gets passed to the variable (col) to add the class 'highlightCol' to a column when one of its 'td's are hovered on. However, If you move the cursor to a new column along a highlighted row, the 'td' you land on has two classes (highlightedRow and package* ). These both get passed to the variable and as a result the new column does not receive the correct class to highlight. Is there a way for me to target just the 'package* ' class and pass that to the variable while ignoring the 'highlightedRow' class? I hope that's not too jumbled for someone to make sense of and many thanks for any help offered.

    Read the article

  • Javascript Callback when variable is set to X

    - by Erik
    Hey everyone, Have an issue I can't seem to wrap my head around. I'm wanting to write a generic javascript function that will accept a variable and a callback, and continue to execute until that variable is something other than false. For example, the variable SpeedFeed.user.sid is false until something else happens in the code, but I don't want to execute a particular callback until it has been set. The call: SpeedFeed.helper_ready(SpeedFeed.user.sid, function(){ alert(SpeedFeed.user.sid); // Run function that requires sid to be set. }); The function: helper_ready: function(vtrue, callback){ if(vtrue != false){ callback(); } else { setTimeout(function(){ SpeedFeed.helper_ready(vtrue, callback); }, SpeedFeed.apiCheckTime); } } The issue I've narrowed it down to appears to be that because in the setTimeout I call vtrue instead of the actual SpeedFeed.user.sid, it's going to be set to false always. I realize I could write a specific function for each time that just evaluates the SpeedFeed.user.sid, but I'd like to have a generic method that I could use throughout the application. Thanks for any insight :)

    Read the article

  • geom_ribbon doesn't work - Error in eval(expr, envir, enclos) : object 'variable' not found

    - by Marciszka
    I try to add a geom_ribbon object to my ggplot2 plot. In my data frame, I have an NA values that (I guess) may cause a problem. This is a reproducible example of data drame I have: base <- c(1:10, rep(NA, 10)) output1 <- c(rep(NA, 9), 10 - 0:10) output2 <- c(rep(NA, 9), 10 + 0:10) xaxis <- 1:20 df <- data.frame(xaxis, base, output1, output2) df xaxis base output1 output2 1 1 1 NA NA 2 2 2 NA NA 3 3 3 NA NA 4 4 4 NA NA 5 5 5 NA NA 6 6 6 NA NA 7 7 7 NA NA 8 8 8 NA NA 9 9 9 NA NA 10 10 10 10 10 11 11 NA 9 11 12 12 NA 8 12 13 13 NA 7 13 14 14 NA 6 14 15 15 NA 5 15 16 16 NA 4 16 17 17 NA 3 17 18 18 NA 2 18 19 19 NA 1 19 20 20 NA 0 20 And my attempt to plot a ggplot2 object with a geom_ribbon: dfm <- melt(df, id=1) ggplot(dfm, aes(x = xaxis, y = value, colour = variable)) + geom_line(aes(group=variable)) + geom_ribbon(data=df, aes(group = 1, ymin=output1, ymax=output2)) And, eventually, I got an error I cannot deal with: Error in eval(expr, envir, enclos) : object 'variable' not found Thank ypu in advance for any suggestions.

    Read the article

  • Best way to determine variable type and treat each one differently in F#

    - by James Black
    I have a function that will create a select where clause, but right now everything has to be a string. I would like to look at the variable passed in and determine what type it is and then treat it properly. For example, numeric values don't have single quotes around them, option type will either be null or have some value and boolean will actually be zero or one. member self.BuildSelectWhereQuery (oldUser:'a) = let properties = List.zip oldUser.ToSqlValuesList sqlColumnList let init = false, new StringBuilder() let anyChange, (formatted:StringBuilder) = properties |> Seq.fold (fun (anyChange, sb) (oldVal, name) -> match(anyChange) with | true -> true, sb.AppendFormat(" AND {0} = '{1}'", name, oldVal) | _ -> true, sb.AppendFormat("{0} = '{1}'", name, oldVal) ) init formatted.ToString() Here is one entity: type CityType() = inherit BaseType() let mutable name = "" let mutable stateId = 0 member this.Name with get() = name and set restnameval=name <- restnameval member this.StateId with get() = stateId and set stateidval=stateId <- stateidval override this.ToSqlValuesList = [this.Name; this.StateId.ToString()] So, if name was some other value besides a string, or stateId can be optional, then I have two changes to make: How do I modify ToSqlValuesList to have the variable so I can tell the variable type? How do I change my select function to handle this? I am thinking that I need a new function does the processing, but what is the best FP way to do this, rather than using something like typeof?

    Read the article

  • In Perl v 5.10.1 on Windows, my variable loses it's value

    - by Sylvia
    I hope this is something straightforward that I'm doing wrong. I saw something online about "variable suicide" that looked good, but it was for an older version and I'm on 5.10.1. Anyway - a variable that I declared - $RootDirectory - just suddenly loses it's value, and I can't figure out why. Here's a script to reproduce the problem. When I run through the script in debug mode (perl -d) I can get it to print out the $RootDirectory at line 21 and 26. But it's gone by line 30. use strict; my $RootDirectory; my @RootDirectories; @RootDirectories = ( 'c:\\P4\\EDW\\PRODEDW\\EDWDM\\main\\db\\' ,'c:\\P4\\EDW\\PRODEDW\\EDWADS\\main\\db\\' ,'c:\\P4\\EDW\\PRODEDW\\FJE\\main\\db\\' ); foreach $RootDirectory (@RootDirectories) { # $RootDirectory = 'c:\\P4\\EDW\\PRODEDW\\EDWDM\\main\\db\\'; # print ' In foreach ' . $RootDirectory. "\n"; RunSchema (); } exit(0); sub RunSchema() { # print ' In RunSchema ' . $RootDirectory. "\n"; CreateTables (); } sub CreateTables() { # print ' In CreateTables ' . $RootDirectory. "\n"; SQLExecFolder ('tbl'); } sub SQLExecFolder() { print ' In SQLExecFolder ' . $RootDirectory. "\n"; # Variable $RootDirectory value is gone by now }

    Read the article

  • Embed URL from variable in HTML file in Rails application

    - by TejasM
    hi, I have a doubt which might be silly for experience Rails developers. I am creating an application which is suppose to embed a video player with URL passed to it. So while displaying i.e in XXX.html.erb file i am writting below code. Now problem is @movie.trailer is my variable in ruby code which has URL value . I want the embedded video to load with URL given by this variable value. Any suggestion how am i suppose to place the value of Ruby variable(@movie.trailer) in part. <object width="425" height="344"> <param name="movie" value="<% @movie.trailer %>"> </param><param name="allowFullScreen" value="true"> </param><param name="allowscriptaccess" alue="always"> </param><embed src="<% @movie.trailer %>" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> Note :- This code is working perfectly fine if i statically give value of URL. Please help

    Read the article

  • Trailing comments after variable assignment subvert comparison

    - by nobar
    In GNU make, trailing comments appended to variable assignments prevent subsequent comparison (via ifeq) from working correctly. Here's the Makefile... A = a B = b ## trailing comment C = c RESULT := ifeq "$(A)" "a" RESULT += a endif ifeq "$(B)" "b" RESULT += b endif ifeq "$(C)" "c" RESULT += c endif rule: @echo RESULT=\"$(RESULT)\" @echo A=\"$(A)\" @echo B=\"$(B)\" @echo C=\"$(C)\" Here's the output... $ make RESULT=" a c" A="a" B="b " C="c" As you can see from the displayed value of RESULT, the ifeq was affected by the presence of the comment in the assignment of B. Echoing the variable B, shows that the problem is not the comment, but the intervening space. The obvious solution is to explicitly strip the whitespace prior to comparison like so... ifeq "$(strip $(B))" "b" RESULT += b endif However this seems error prone. Since the strip operation is not needed unless/until a comment is used, you can leave out the strip and everything will initially work just fine -- so chances are you won't always remember to add the strip. Later, if someone adds a comment when setting the variable, the Makefile no longer works as expected. Note: There is a closely related issue, as demonstrated in this question, that trailing whitespace can break string compares even if there is no comment. Question: Is there a more fool-proof way to deal with this issue?

    Read the article

  • Radio buttons change variable in JavaScript

    - by dmanexe
    I have two fields which calculate a total, but I have a radio button pair that determines a variable within the equation. Here's the radio button code: <input type="radio" name="estimate_pool_shape" value="1" /> Angle <input type="radio" name="estimate_pool_shape" value=".86392" /> Freeform Immediately after that, this JavaScript is then calculating the surface area of the pool based of these fields and script: (Length <input type="text" size="5" name="estimate_pool_length" onBlur="conv2inches(document.forms.mainform);" />) x (Width <input type="text" name="estimate_pool_width" size="5" onBlur="conv2inches(document.forms.mainform);" />) The following JavaScript already works to update the fields, I just need the variable it uses to set the field values to change based on the radio buttons. function conv2inches(mainform) { var oin; var oinches; if(isNaN(mainform.estimate_pool_width.value)||isNaN(mainform.estimate_pool_length.value)){ alert("Please enter numbers only"); return false; } oin = ((mainform.estimate_pool_width.value) + (mainform.estimate_pool_length.value) * %%%RADIO BUTTON VARIABLE HERE%%%); oinches = (oin); if(oinches==0){ alert("Please enter valid values into the boxes"); } mainform.estimate_pool_sqft.value = oinches; return false; }

    Read the article

  • Determining an object's variable name dynamically?

    - by ZenBlender
    Let's say I have some objects: ArrayList<SomeObject> list = new ArrayList<SomeObject>(); SomeObject A = new SomeObject(); SomeObject B = new SomeObject(); SomeObject C = new SomeObject(); SomeObject D = new SomeObject(); These constructors automatically add each object to the ArrayList so I can iterate over them but still maintain the variable names for direct access: public SomeObject(){ // init stuff here list.add(this); } But then, let's say I want to output some debug info, and iterate through list and print out the NAME of each object? How can I do that? Essentially, when "SomeObject A = new SomeObject();" is executed, I want to use reflection (if possible) to determine that this variable's name is "A" (a String) and either store that in the object when the constructor executes, or determine it dynamically through reflection when referencing this object with the variable named "A". Does that make sense? How can I do this? Thanks!

    Read the article

  • $_POST Variable Detected in Chrome but not in Firefox

    - by user1707973
    I am using 2 images in a form to sort out query results from the database. The form is submitted using the POST method. When i click on the first image, the query results have to be sorted in ascending order, and when i click on the second, the results have to be sorted in the descending order. This is the code for the form: <form name="" action="" method="post"> <input type="hidden" name="typep" value="price" /> <input type="image" name="sort" value="asc" src="images/asc-ar.png" /> <input type="image" name="sort" value="desc" src="images/dsc-ar.png" /> </form> Now this is the code for checking if the $_REQUEST['sort'] variable is set and therefore whether sorting is required or not. if ($_REQUEST['sort'] != "") { $sort = $_REQUEST['sort']; $typep = $_REQUEST['typep']; //query to be executed depending on values of $sort and $typep } Firefox does detect the $_REQUEST['typep'] variable but not the $_REQUEST['sort'] one. This works perfectly in Chrome though. When i test the site in Firefox, it doesn't detect the $_REQUEST['sort'] variable and therefore the if condition evaluates to false and the search results don't get sorted.

    Read the article

  • Passing Javascript value to PHP Variable using ajax

    - by shels
    I am trying to use a Flash detection script to assess whether Flash Plugin is enabled in the user browser so that a different page loads. The Flash detection script is as follows, using jquery 1.8.2 and jquery.jqplugin 1.0.2 <script type="text/javascript" src="jquery-1.8.2.min.js"></script> <script type="text/javascript" src="jquery.jqplugin.1.0.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#withflash").hide(); $("#noflash").hide(); if ($.browser.flash == true) $("#withflash").show (); else $("#noflash").show (); }); </script> <div id="withflash">Flash Supported</div> <div id="noflash">Flash Not Supported</div> I get the display that "Flash Supported" if Flash Plugin is present.. I need to capture the value whether flash plugin value is true in a php variable $hasFlashSupport as below: <?php echo " $hasFlashSupport"; exit; ?> I am aware that PHP is server based and Javascript is client based.. Hence Ajax would be a nice option to capture the javascript variable to my php variable. I am totally ignorant about Ajax syntax and how to achieve it. Request the experts here to help me out with the code on how this can be achieved... Thanking all of you in advance..

    Read the article

  • Calculating with a variable outside of its bounds in C

    - by aquanar
    If I make a calculation with a variable where an intermediate part of the calculation goes higher then the bounds of that variable type, is there any hazard that some platforms may not like? This is an example of what I'm asking: int a, b; a=30000; b=(a*32000)/32767; I have compiled this, and it does give the correct answer of 29297 (well, within truncating error, anyway). But the part that worries me is that 30,000*32,000 = 960,000,000, which is a 30-bit number, and thus cannot be stored in a 16-bit int. The end result is well within the bounds of an int, but I was expecting that whatever working part of memory would have the same size allocated as the largest source variables did, so an overflow error would occur. This is just a small example to show my problem, I am trying to avoid using floating points by making the fraction be a fraction of the max amount able to be stored in that variable (in this case, a signed integer, so 32767 on the positive side), because the embedded system I'm using I believe does not have an FPU. So how do most processors handle calculations out of the bounds of the source and destination variables?

    Read the article

  • Variable from block is put into a calculation but throws off wrong reading

    - by user2926620
    I am having troubles with trying to retrieve a double variable that is already established outside the block and called inside but I want to return the value of the same variable so that I can apply it to a calculation. the variable that I want returned is: double quarter = 0; but when I plug it into quarter in my first else/if statement, it plugs in 0 and not the value in my switch block. What can I do to retrieve the value? double quarter = 0; //Date entry will be calculated by how much KW user enters switch (input) { case "2/15/13": quarter = kwUsed * 0.10; break; case "4/15/13": quarter = kwUsed * 0.12; break; case "8/15/13": quarter = kwUsed * 0.15; break; case "11/15/13": quarter = kwUsed * 0.15; break; default: System.out.println("Invalid date"); } //Declaring variables for calculations double base = 0; double over = 0; double excess = 0; double math1 = 0; double math2 = 0; //KW Calculations if (kwUsed <= 350) { base = quarter; }else if (kwUsed <= 500) { math1 = ((kwUsed - 350) * quarter); base = ((kwUsed * quarter) - math1); over = ((math1 * 0.1) + math1); }else if (kwUsed > 500) { math2 = ((kwUsed - 350) * 0.1); base = ((kwUsed * 0.1) - math2); math2 = ((kwUsed -350) - 50); over = ((math2 * 0.1) + (15 * 0.1)); double math3 =((kwUsed - 500) * 0.1); excess = ((math3 * 0.25) + math3); } Edited to clarify question.

    Read the article

  • Which way of declaring a variable is fastest?

    - by ADB
    For a variable used in a function that is called very often and for implementation in J2ME on a blackberry (if that changed something, can you explain)? class X { int i; public void someFunc(int j) { i = 0; while( i < j ){ [...] i++; } } } or class X { static int i; public void someFunc(int j) { i = 0; while( i < j ){ [...] i++; } } } or class X { public void someFunc(int j) { int i = 0; while( i < j ){ [...] i++; } } } I know there is a difference how a static versus non-static class variable is accessed, but I don't know it would affect the speed. I also remember reading somewhere that in-function variables may be accessed faster, but I don't know why and where I read that. Background on the question: some painting function in games are called excessively often and even small difference in access time can affect the overall performance when a variable is used in a largish loop.

    Read the article

  • create variable from array actionscript 3

    - by steve
    I'm currently trying to make a dynamic menu via an array and a loop. So when someone clicks on the first item of the array, "menu_bag_mc" it will link to the content "menu_bag_mc_frame" (or some name that will be unique to this array) that is another movieclip that will load. Below is the code I have so far: //right here, i need to make a variable that I can put in the "addchild" so that //for every one of the list items clicked, it adds a movieclip child with //the same name (such as menu_bag_mc from above) with "_frame" appended. //I tried the next line out, but it doesn't really work. var framevar:MovieClip = menuList[i] += "_frame"; function createContent(event:MouseEvent):void { if(MovieClip(root).currentFrame == 850) { while(MovieClip(root).numChildren > 1) { MovieClip(root).removeChild(MovieClip(root).getChildAt(MovieClip(root).numChildren - 1)); } //Here is where the variable would go, to add a child directly related //to whichever array item was clicked (here, "framevar") MovieClip(root).addChild (framevar); MovieClip(root).addChild (closeBtn); } else { MovieClip(root).addChild (framevar); MovieClip(root).addChild (closeBtn); MovieClip(root).gotoAndPlay(806); } } Is there a way to make a unique variable (whatever it is) from the array so that I can name a movieclip after it so it will load the new movieclip? Thanks

    Read the article

  • Change Stylesheet via If in php

    - by mikep
    Hey i have a question. At the moment i'm trying to use a stylesheet which i get through a if. but it doesn't do anything. here is my code at the moment. the variable $stylesheet will be variable but while testing i've setted it to normal <?php $stylesheet = 'normal' if($stylesheet = 'small') { $style = './sitestyle/stylesheetsmall.css'; } if($stylesheet = 'big') { $style = './sitestyle/stylesheetbig.css'; } else { $style = './sitestyle/stylesheet.css'; } echo '<link rel="stylesheet" type="text/css" href="$style">'; ?> Thanks for your answers.

    Read the article

  • How do I access variables with hyphenated names in Smarty?

    - by abeger
    I've got a PHP page that parses an XML file with SimpleXml, then passes that object to a Smarty template. My problem is that the XML file has hyphens in its tag names, e.g. video-player. In PHP, this is no problem, I just use $xml->{'video-player'} and everything's fine. Smarty, on the other hand, throws a fit when I try to use that syntax. The only solution I've come up with so far is to use a variable to store the name, e.g., { assign var=name value="video-player" } { $xml->$name } But this isn't terribly graceful to say the least. Is there another, better, approach to referring to a hyphenated variable name in Smarty?

    Read the article

  • Access variables from a number of sources

    - by mac_55
    I'm creating my first game, and I've currently set up a 'GameState' class, to store player health etc. inside. This class is currently instantiated from the AppDelegate as I need to access it from all over my game. This is fine. For each class I'm working in, I can access the app delegate, and then find the GameState object... however, it seems very messy. I'm tempted to find a way (I'm still a newbie) to define the GameState instance as being some sort of global variable so that I can access it from all over with ease... but my little bit of reading on variable scope makes me uneasy about doing this, even if I knew how. Any ideas of the best way to define and access this class? It'll be used for everything from player health, to items they've found, any personalisation etc. Thanks!

    Read the article

  • Making your own "int" or "string" class

    - by amerninja13
    I disassembled the .NET 'System' DLL and looked at the source code for the variable classes (string, int, byte, etc.) to see if I could figure out how to make a class that could take on a value. I noticed that the "Int32" class inherits the following: IComparable, IFormattable, IConvertible, IComparable, IEquatable. The String and Int32 classes are not inheritable, and I can't figure out what in these inherited interfaces allows the classes to hold a value. What I would want is something like this: public class MyVariable : //inherits here { //Code in here that allows it to get/set the value } public static class Main(string[] args) { MyVariable a = "This is my own custom variable!"; MyVariable b = 2976; if(a == "Hello") { } if(b = 10) { } Console.WriteLine(a.ToString()); Console.WriteLine(a.ToString()); }

    Read the article

  • Is it kEatSpeed or kSpeedEat?

    - by bobobobo
    I have a bunch of related constants that are not identical. What's the better way to name them? way #1 kWalkSpeed kRunSpeed kEatSpeed kDrinkSpeed Or, way #2 kSpeedWalk kSpeedRun kSpeedEat kSpeedDrink If we evaluate these based on readability understandability not bug prone with subtle errors due to using wrong variable name I think way #1 wins readability, they tie for understandability, and way #2 wins for not bug prone. I'm not sure how often it happens to others, but when variable names like this get long, then its easy to write kSpeedEatingWhenInAHurry when you really meant kSpeedEatingWhenInHome, especially when using autocomplete. Any perspectives?

    Read the article

  • Why use constants in programming?

    - by Adam N
    I've just been going back over a bit of C studying using Ivor Horton's Beginning C book. I got to the bit about declaring constants which seems to get mixed up with variables in the same sentence. Just to clarify, what is the difference in specifying constants and variables in C, and really, when do you need to use a constant instead of a variable? I know folks say to use a constant when the information doesn't change during program execution but I can't really think of a time when a variable couldn't be used instead. Thanks

    Read the article

  • unique random id

    - by Piyush
    I am generating unique id for my small application but I am facing some variable scope problem. my code- function create_id() { global $myusername; $part1 = substr($myusername, 0, -4); $part2 = rand (99,99999); $part3 = date("s"); return $part1.$part2.$part3; } $id; $count=0; while($count == 1) { $id; $id=create_id(); $sqlcheck = "Select * FROM ruser WHERE userId='$id';"; $count =mysql_query($sqlcheck,$link)or die(mysql_error()); } echo $id; I dont know which variable I have to declare as global

    Read the article

  • Has anyone else had problems with the miserable kb980408 update?

    - by Dan
    I wasn't experienced any problems before installing kb980408 for Windows 7 x86. The update made it impossible for me to log into my computer after displaying a "Setting up personalized settings for Windows Desktop Update" message, after killing that task a "Windows Explorer is not responding - Windows is checking for a solution to the problem" message appears, then it waits forever... If I killed that task, I was not able to continue the boot process, if I ran explore.exe manually, the same thing happens. The solution, by the way, was to boot into safe mode and use the add/remove program in the control panel to uninstall this wretched piece of code. Start-up repair and/or the use of system restore will not help you, you need to uninstall.

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >