Getting a datatype (specifically an array of doubles)
I'm looking for a way to write a constructor that will simply check to see whether or not an array is an array of doubles, and if not, will throw an illegal datatype message.
These are just the parameters for reference...:
public Triangle (double[] array, boolean dataType) throws IllegalTriangleException {
//checks if the array is an array of doubles
throw new IllegalTriangleException ("This is not an array of doubles");
}//end Triangle constructor
i think i just haven't got the question !
If you've got an array of doubles then there are doubles only!
If youve' got a mixed list, you can use
Double.isNaN()
in iterations. isNAN() will be true for each element that is not a number!
Similar Messages
-
I have a 1-D array of double inside of a while loop. I would like to control the execution of the while loop based on one of the numeric values in that array (like I would stop the while loop if the numeric value in the array is less than or equal to 0). How should I go about doing this?
I cant link the array directly to the "less than or equal to 0" icon because it requires a single double. Any help would be much appreciated. Thanks.
Jerryqiora wrote:
I cant link the array directly to the "less than or equal to 0" icon because it requires a single double.
Of course you can connect an array to "less than or equal to 0". The output will be a boolean array that you can feed into a "OR array elements" or "AND array elements" to get a true if either (1) at least one array element matches or (2) all elements match, respectively.
qiora wrote:
I would like to control the execution of the while loop based on one of the numeric values in that array (like I would stop the while loop if the numeric value in the array is less than or equal to 0).
If it should be based on one specific element (e.g. element(0) or element(5)), you need to get that element using "index array" and do the comparison.
The implementation will depend on your exact requirement. Your question is quite ambiguous.
LabVIEW Champion . Do more with less code and in less time . -
I want to cast Array to double[]
I make an windowsForm class for draw graph.
It has an input param
public FormGraph(string title, string name1, Array data1)
I need data of double[] type for draw graph. But I think users are want to input double[] or int[] ect...
So I try to get data as Array type and cast it to double[].
double[] series1 = (double[])data1;
But it throw exception about fail to cast.
How can I cast variable type of array to double[]?Another option is to combine Generics with this.
You can use generics to allow the users to pass different types of data to a method, but type specific in a different way.
public FormGraph<T>(string title, string name1, IEnumerable<T> data1)
var series1 = data1.Select(x => Convert.ToDouble(x)).ToArray();
Muthukrishnan Ramasamy
net4.rmkrishnan.net
Use only what you need, Reduce global warming -
Source is double sink is 1D-array of double
I am getting this message when I wire something.
These cannot be wired together because the data types do not match. The type of the source is double. The type of the sink is 1D-array of double.
What is source and sink?Anything that produces data is a source. Think of it like watering your
yard. The sprinkler is the source of teh water, the grass is the sink.
If you want all the data from the loop, then you DO
want auto indexing enabled. This is what automatically builds the array
on the edge of the loop. If you da as Altenbach suggested, you'll have
the correct indicator for the array.
The problem you may be having is that now that you have an array, you
have to use the array functions to get at the individual values in the
array. To get to a single element, wire the array into the "Index
Array" function. The 'Index' input specifies which element wil be
passed through the function. a '0' will give you the first element, a 1
will give you the second element and so on.
Does that take care of the problem?
Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences. -
I am trying to get to a specific spot on a website. I have signed on and can get to all other sections, but when I try to get to this one section I get a message back saying Safari cannot get to that page, too many redirects? Help?
Clear. Safari, close it and reset your iPad.
Go to Settings>Safari>Clear Cookies and Data.
To close an app, drag the app up from the multitasking display. Double tap the home button and you will see apps lined up going left to right across the screen. Swipe to get to the Safari app and then swipe "up" on the app preview thumbnail to close it.
Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up. -
How to write a 2-D Array of Doubles to a binary file in LabView 8.5?
Okay, this is driving me nuts. I got a program that worked fine in LabView 8.0 but refused to write any data after my institute upgraded to LabView 8.5. The data is stored in a 2-D array of doubles and is supposed to be written to a binary file, that has been correctly opened and got a header written to it containing some meta-data of the measurement. But when the doubles from the array should be written to the file, nothing happens. All I get is an (except for the header) empty file of 786 kB. I found out that writing works if I convert the data from the array to singles right before wiring them to the "write to binary file" VI, but for several reasons I need the data as doubles. Can anyone help me? I've tried everything anyone has written here about writing to binary files and more.
Remember, it worked perfectly fine with an older version of LabView. Any ideas?It is possible that you run into a known memory optimization bug.
Try to place an "always copy" primitive as discussed here.
Message Edited by altenbach on 11-18-2008 09:11 AM
LabVIEW Champion . Do more with less code and in less time . -
Array of doubles filled by DLL contains weird values
Hello everyone
I am working on a DLL invocation which needs to resize and fill an array of doubles named 'values' (2nd to last parameter). I have defined the signature as follows:
_declspec (dllexport) uint8_t readDoubleArray(uint8_t handle, LStrHandle lPath, int64_t startTime,
int64_t endTime, DblArrHdl *values, LongArrHdl *timebase);
Where DblArrHdl is
typedef struct {
int32_t dimSize;
double doubles[1];
} DblArr;
typedef DblArr **DblArrHdl;
In the invocation I read doubles from a database, and resize the double array as follows:
int size = doubleArray.size();
if (NumericArrayResize(0x0A, 1, (UHandle*)values, size) != noErr) {
setLastError(MG_ERR_LABVIEW_ERROR, "Failed to allocate memory");
return FALSE;
I set the size, and copy the values:
(**values)->dimSize = size;
for (int i = 0; i < size; i++) {
(**values)->doubles[i] = doubleArray[i];
When I use the DbgPrintF to validate the values it gives me a value around 120000 which is correct. However, when returned by labview the array contains strange data, like 5.38564E-315. Here is print out of the 'values' array after it has been through the DLL:
Here is how I wired it, ignore the clustering, it occurs in the array of values which exits the DLL call.
I have no idea how this can be. I followed the examples on the site. I also tried the normal DSSetHandleSize, but it didn't change anything. Any idea what I did wrong?
Thanks in advance,
Vincent
Message Edited by DaVince on 10-22-2008 10:10 AM
Solved!
Go to Solution.
Attachments:
doubleArrayWeird.png 7 KB
wireUpDoubles.png 18 KBYou're right, this not directly described...
First you should read how LabVIEW stores data in memory,
then read about structure packing pragma,
and finally take a look to C/C++ preprocessor reference,
then you will get feeling how to solve this problem...
Otherwise own DLLs used in LabVIEW code pretty rarely, and Double precision also not very often...
The same trouble you may get with clusters, but here behaviour described:
"...The memory layout of a cluster depends on the platform you are running. LabVIEW may add padding between cluster elements so that those elements are aligned to certain address boundaries. Address boundaries relate to the concept of natural alignment. A piece of data is aligned on its natural boundary if the address at which it begins is a multiple of the size of the data. For example, a 4-byte integer is aligned naturally if it begins at an address which is a multiple of four. Most compilers have an upper limit on this boundary at which the restriction is relaxed. For instance, an 8-byte integer may be aligned on a 4-byte boundary. For the platforms on which LabVIEW runs, the alignment constraints are as follows:
(Windows) Data is aligned only to 1-byte boundaries.
(Mac OS and Linux) Data is aligned naturally up to 4-byte boundaries.
(VxWorks PowerPC) Data is aligned naturally up to 8-byte boundaries.
On all platforms, clusters adopt the alignment of their most restrictively aligned element..."
best regards and happy wiring...
Andrey.
Message Edited by Andrey Dmitriev on 10-23-2008 03:38 PM -
How to get the values of an Array using JSP Tags
Hey guys,
I need some help. I've splited a String using
fn:split(String, delim) where String = "1,2,3,4" and delim is ,
This method returns an Array of splited Strings. how do i get the values from this array using jsp tags. I don't wanna put java code to achive that.
Any help would be highly appreciated
ThanksThe JSTL forEach tag.
In fact if all you want to do is iterate over the comma separated list, the forEach tag supports that without having to use the split function.
<c:set var="list" value="1,2,3,4"/>
<c:forEach var="num" items="${list}">
<c:out value="${num}"/>
</c:forEach>The c:forTokens method will let you do this with delimiters other than a comma, but the forEach tag works well just with the comma-delimited string. -
How to get the record set into array?
Hi,
I want to get the record set into array in the procedure and do the processing of the array later in procedure.
below is the stored procedure i am working on:
procedure bulk_delete_group(p_group_id in Array_GroupListID) as
begin
for i in p_group_id.first..p_group_id.last loop
--Here I have to get the list of user id before deleting group
SELECT user_id into *<SOME ARRAY>* FROM group_members WHERE group_id = p_group_id(i);
DELETE group WHERE group_id = p_group_id(i);
--Process the user id array after group deletion..
end loop;
end bulk_delete_group;
Thanks in advance
AdityaSomething like this ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.20
satyaki>
satyaki>
satyaki>select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 4450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 7000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
13 rows selected.
Elapsed: 00:00:02.37
satyaki>
satyaki>create type np is table of number;
2 /
Type created.
Elapsed: 00:00:03.32
satyaki>
satyaki>Create or Replace Procedure myProc(myArray np)
2 is
3 i number(10);
4 rec emp%rowtype;
5 Begin
6 for i in 1..myArray.count
7 loop
8 select *
9 into rec
10 from emp
11 where empno = myArray(i);
12
13 dbms_output.put_line('Employee No:'||rec.empno||' Name:'||rec.ename);
14 end loop;
15 End myProc;
16 /
Procedure created.
Elapsed: 00:00:00.88
satyaki>
satyaki>
satyaki>declare
2 v np:=np(9999,7777);
3 begin
4 myProc(v);
5 end;
6 /
Employee No:9999 Name:SATYAKI
Employee No:7777 Name:SOURAV
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.30
satyaki>Regards.
Satyaki De. -
How do you get the average of an array bigdecimels
how do you get the average of an array bigdecimels... I am looping through the array in a for loop
for (int i = 0; i < prItems.length; i++) {int sum = 0;
for (int i = 0; i < prItems.length; i++) {
sum = sum + prItems;
int avg = sum/prItems.length; -
Reading arrays of double from S7 with OPC & Datasocket
Hi friends:
We are developing an application with a S7-315-2DP PLC and a PC with a PCI1500PFB. We use the OPC server from Applicom. We read the data very quickly with the datasocket (arrays of boolean, arrays of doubles ...and so on, and a very big amount of data over 100 ms) but when we try to write arrays datasocket faield and we have to write item on item and the speed decrease. For intance, if we try to write doubles ( 50 items) the refresh period is over 5 seconds ( some times more since we launch the data and we read the same data on the PC). Perhaps we failed configuring the OPC but there isn´t many things to configure, perhaps the problem is the board configuration .. I don´t know.
We
try to find some examples that write an array of doubles on one time but..
Thank you for yours answers.
JaviHi Javi,
I'm not aware of any known issues writing to the Applicom OPC server. In LabVIEW there isn't anything special you need to configure to be able to write arrays of doubles through DataSocket. You can test this by using the DataSocket Server Manager, make a new member that is an array of doubles, and try reading and writing to that member. You may also want to check to make sure the data member the OPC server is expecting is an arry of doubles and not an array of singles or integers. -
How to get the system specific hardware key.
Hi all,
I want to get the System specific hardware key(May be Hard disk related key which is unique for every System.) .Now i need to get it using a java program. if possible send me the related links and sample source code. pls help me out to resolve this issue.
Regards,
Kiran.hi,
I can able to get the Mac address of computer using the java program. But when i am running a software called "PCQualifier.exe" i am getting the parameters like "uniqueID" and "unique code". so where and how he is getting those things please help me to get those things using a java programme. Any how i am sending the results that i have got after ruuning PCQualifier.Pls kindly help me out to resolve this issue.
Computer Name JAVADEV0005
Operating System Windows XP 5.1 build 2600 (Service Pack 2)
Ethernet Details Name [00000008] Broadcom NetXtreme Fast Ethernet Adapter Type Ethernet 802.3
MAC Address 00:11:25:F2:98:EF
Hard Disk Capacity Total 39.06GB
Used 84 %
Free 6.16GB
RAM Capacity Total 502 Mbyte
Used 69 %
Free 154 Mbyte
CDROM Status CD-ROM Drive Present
USB Information
Total system supported Ports 0
Total Physical Ports 0
Total Devices Connected 0
Total Free Ports 0
Unique ID 5790315021
Unique Code FNVVEFEFHIKO
Thanks & Regards
Kiran. -
Transfering elements to new array and doubling values.
Hi my problem is that I need to ask a user to enter 5 integers that stores them in an array. Transfer them to a new array by doubling the values when trasferred.
Please help I have 3 errors.
class arrays
public static void main (String[] args)
int numbers[] = new int [5];
byte array1Size = 0;
int input = 0;
char goon = 'y';
//create and initialise an array of 5 integers
int array1[] = new int [5];
// loop and fill each element
for (int x = 0; x < array1.length; x++)
System.out.println("Enter a number: ");
array1[x] = EasyIn.getInt();
// Filling array
if (array1Size >= array1.length)
//Make a new array doubling the values od the integers
int array2 [] = new int [2 * array1.length]; // 10 integers
//Copying integers
System.arrayCopy (array1, 0, array2, 0, array1.length);
//Make old reference point to new array
array1 = array2;
else
//normal
do
System.out.print("Enter an integer: ");
input = EasyIn.getInt();
anotherArray[anotherArraySize] = input;
anotherArraySize++;
System.out.print ("Another number? Enter Y or N: ");
goon = EasyIn.getChar();
} while(goon = = 'y' | goon = = 'Y');
the errros >>>
G:\Java\Practical 7\Practical74.java:33: '.class' expected
int array2 [] = new int [2 * array1.length]; // 10 integers
^
G:\Java\Practical 7\Practical74.java:33: not a statement
int array2 [] = new int [2 * array1.length]; // 10 integers
^
G:\Java\Practical 7\Practical74.java:41: 'else' without 'if'
else
^
3 errors
Tool completed with exit code 1
ThanksHi,
it seems you forgot the curly braces in the if-else statement:
if (array1Size >= array1.length){
//Make a new array doubling the values od the integers
int array2 [] = new int [2 * array1.length]; // 10 integers
//Copying integers
System.arrayCopy (array1, 0, array2, 0, array1.length);
//Make old reference point to new array
array1 = array2;
else{
//normal
do
System.out.print("Enter an integer: ");
input = EasyIn.getInt();
anotherArray[anotherArraySize] = input;
anotherArraySize++;
System.out.print ("Another number? Enter Y or N: ");
goon = EasyIn.getChar();
} while(goon = = 'y' | goon = = 'Y');
} -
I need to display an array of doubles on a table and I am loosing my percision
Hello,
I need to display an array of doubles on a table but I am losing my decimal precision. I am converting the array to a string in order to display it on the table with a number to decimal function. This is where I lose my precision since that control converts the double into an integer and then into the string. What control do I need to use instead of that in order to preserve my decimal precision all the way to the table? I have attached my VI. Thanks in advance!
Gregory Osenbach, CLA
Fluke
Attachments:
canalyzer_prototype_1.vi 52 KBThank you both for the quick response. Its just the info I needed!
Gregory Osenbach, CLA
Fluke -
FM to get the date specific structural help
I am working on structural help for Org id for a selection screen parameter.
I am using FM RH_OBJID_REQUEST. It is giving the structure valid ion today. My requirement is to get the structure valid on given period in the above selection field.
Please let me know is there any other way(other FM) to get the date specific structural help.Pass your dates to ORGBEG & ORGEND
Description
This parameter only applies to the search function.
The parameters ORGEND and ORGBEG together determine the period in which
the organizational assignment data for positions is read. The entry in
ORGBEG specifies the start of the search period.
Value range
Allowed values are all dates smaller than the date in ORGEND.
Default
The default value is the smallest system date.
Function Module
^Saquib
Maybe you are looking for
-
Help! Male / Boy Flash Avatars Needed
Dear Community, I'm in desperate need of great quality 3D male/boy avatars needed for my E-Learning Demo for Professional Accountants. Please advise of any site or directory where I can find or buy such avatars. Much appreciated. Wes du Toit
-
How to restore clock in locked screen?
how to restore the clocked while your iphone is locked? for some reason mine changed to the safari play menu
-
Camera Calibration worth it?
I'm looking at the x-rite colorchecker passport for camera calibration in LR/ACR, I've read some reviews and tutorial vids and for $99 seems like a no-brainer, though, on the flip side, I did read someone who said that it is more useful for studio/ta
-
Dear all, I have know idea about HR module 1)let me know how to assign the DIR to HR object through PA30. i am unable to attache the DIR at same . DIR window is not comming. 2) I have assigne th HR object to document type. I can see three field in hr
-
Missing video chat icon, how do i get it back
i think i deleted it when i had v1.08. i thought under 2.0, it would do a full install, but it did not. i did a factory wipe, no luck. i tried to reinstall os, but no luck, it went through the proces of downloading and installing, but did not add a