|
Why are you converting numbers to strings and then concatenating them all into an unparsable list? The only time you need to convert them to strings is when displaying or printing. Inside your application you should keep them as doubles at all times.
|
|
|
|
|
I need to model multivariate polynomials where the number of variables depends on user input. I found it natural to model univariate polynomials as arrays of numbers representing the coefficients, whose indices represent the degrees of the terms they correspond to. The obvious extension to n-variable polynomials is an n-dimensional array, the index of an entry with respect to a given dimension representing the degree of the term with respect to a given one of the variables. However, it seems like it would be tricky to declare and manipulate such an object - I can't type int[][]...[] (n sets of brackets), after all. Alternatively, I could given up on the idea of encoding term degree in the positions of entries in the data structure, perhaps using a dictionary where the values are the coefficients and the keys are one-dimensional, n-element arrays specifying the degree of the term, but this approach would mean it would be necessary to do a bunch of searches every time the polynomial is operated on, which seems inelegant. Are there any other approaches I should consider?
|
|
|
|
|
I've come up with an n-dimension array class:
class ndArray
{
int Dimensions;
int DimensionLength;
int[] Array;
public ndArray(int dimensions, int dimensionLength)
{
Dimensions = dimensions;
DimensionLength = dimensionLength;
int arrayLength = 1;
for (int i = 0; i < dimensions; ++i)
arrayLength *= dimensionLength;
Array = new int[arrayLength];
}
int getIndex(params int[] indices)
{
int index = 0;
int nsPlace = 1;
for (int i = 0; i < Dimensions; ++i)
{
index += indices[i] * nsPlace;
nsPlace *= DimensionLength;
}
return index;
}
public int getElement(params int[] indices)
{
return Array[getIndex(indices)];
}
public void setElement(int element, params int[] indices)
{
Array[getIndex(indices)] = element;
}
}
I'll have to see how this works in the context of polynomials. Maybe the static limit on dimension length will be a problem.
|
|
|
|
|
|
Frequency of spreading what?
This space for rent
|
|
|
|
|
\\
How can I create a program that shows information on DVB-T2 USB and shows it in a noutbook ???
|
|
|
|
|
That makes no sense at all. About the best you're going to get for an answer is to consult the documentation and manufacturer support for the device you're trying to use.
If you have to ask "How do I write an entire application?", you're not going to get an answer for that question. It's a very generic question and impossible to answer with any accuracy at all.
|
|
|
|
|
How do I link sliders together? Or trackbars.
I want to have 3 sliders set up so they are linked. So one slide bar can have 1 million and then as I use the other sliders that number will go down as the numbers go up in the other sliders.
Also, how do I get a slider to show the number above where my slider is? So if the slider is on 1 million it shows the text above my cursor as 1,000,000 and if I move it down the number decreases as I move the slider down.
|
|
|
|
|
What have you tried? Where are you stuck?
|
|
|
|
|
Step one is to get a slider control and see what properties and events it exposes. Then go from there.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
This is easy to do with TrackBar Controls in WinForms, but, first, you have to precisely define what "linkage" is: do the TrackBars have independent value ranges, or, over-lapping ranges ?
If changing one TrackBar's value can change the other TrackBars' values, you'll need to prevent recursion.
Need a "read-out:" position a Label over the TrackBar and use that, or use a ToolTip.
Clarify your goal, and show some code.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
I want one track bar to hold the total of the other track bars. So if the total is 100 the track bars added together can't add up to greater than 100.
Track bars set out like say:
10
20
50
20
Total 100
Or
30
10
30
30
Total 100
|
|
|
|
|
Okay, this a good first step in specifying behavior.
The next step is to define the minimum and maximum range for each trackbar; of course, you can change this at run-time with code.Member 13670442 wrote: one track bar to hold the total of the other track bars Are you saying that this trackbar sets the maximum value of the total of values of the other trackbars ? If so, how would changing its values affect the current values of the other trackbars ?
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Yes. The other track bars would be limited by the Total track bar. If the Total track bar is 100 all the track bars must add up to that track bar and no more. If I were to move the Total track bar down the other track bars move down too. Until they react zero.
50
10
10
10
10
Total 90
10
0
0
0
10
Total 20
If having the Total track bar isn't possible I could do it without a Total tack bar. I just need the code that will link multiple track bars together.
|
|
|
|
|
I'm trying to write an algorithm in C#, this algorithm includes so many transfer function in laplace space, such as 2nd order high-pass or low-pass filters, integrals and derivatives, I converted all of them into discrete form, but I don't know how to add them to my C# code. for example how can I implement this transfer function in C# code:
H(z)= 4/(2z+3)
|
|
|
|
|
Maybe I'm missing something, but isn't your example just:
public double H(double z)
{
return 4.0 / ( 2.0 * z + 3.0);
}
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I am making a DAQ-Simulator that shall simulate generation of analog (0-1V) and digital 1 or 0 signals.
When I call my method sampling () and display the sensor data in my textbox, I always get the same numbers for my Analog sensors. Since this is a Random generation it should have been different numbers every time I click on Sample button
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
<pre lang="c#">namespace DAQ_Simulator
{
public partial class Form1 : Form
{
int counter;
int maxSid = 10;
int maxAI, maxDI;
string sTxt;
private DateTime datetime;
Sensor[] sObj = new Sensor[10];
public Form1()
{
InitializeComponent();
}
private void displaySensorData(object sender, EventArgs e)
{
}
private void groupSampl_Enter(object sender, EventArgs e)
{
}
private void textSampling_TextChanged(object sender, EventArgs e)
{
}
private void btnSampling_Click(object sender, EventArgs e)
{
sampling();
}
private void groupLogg_Enter(object sender, EventArgs e)
{
}
private void txtLogging_TextChanged(object sender, EventArgs e)
{
}
private void labelLoggingText_Click(object sender, EventArgs e)
{
}
private void btnLogging_Click(object sender, EventArgs e)
{
}
private void labelSensorValues_Click(object sender, EventArgs e)
{
}
private void textSensorValues_TextChanged(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void sampling()
{
for (counter = 0; counter < maxSid; counter++)
{
sObj[counter] = new Sensor(counter);
}
for (counter = 0; counter < maxSid; counter++)
{
for (counter = 0; counter < 10; counter++)
{
sObj[counter] = new Sensor(counter);
}
for (counter = 0; counter < maxSid; counter++)
{
sTxt += sObj[counter].GetAnalogValue().ToString("F3");
textSensorValues.Text = sTxt;
}
textSensorValues.Text=sTxt;
}
}
}
}
This is my Sensor class where I call the GetAnalogValue() from:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DAQ_Simulator
{
public class Sensor
{
double dVal;
bool bVal;
int sId;
Random rSensVal;
public Sensor(int id)
{
sId = id;
rSensVal = new Random(id);
dVal = 0.0F;
}
public double GetAnalogValue()
{
dVal += rSensVal.NextDouble();
return dVal;
}
public int GetDigitalValue()
{
Random bVal = new Random(2);
int digital = bVal.Next(2);
return digital;
}
public int GetSensId()
{
return sId;
}
modified 8-Feb-18 12:54pm.
|
|
|
|
|
You're specifying the same seed each time, so you'll get the same sequence of pseudo-random numbers each time.
You can generate the same sequence of random numbers by providing the same seed value to the Random(Int32) constructor.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Your Random instance is a local variable, which means you create a new one each time you call the GetDigitalValue method. Since the Random constructor begins the sequence with a seed value based on the computer clock, if you create several Random instances close together, it is very likely - particularly with modern fast computers - that the same seed value will be used, and as a result all teh instances will generate the same sequence.
Change your Random instance to a private static variable, and you will get different results.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Since the Random constructor begins the sequence with a seed value based on the computer clock, ...
Except in the posted code, where each instance is passed a seed value. Either the index of the sensor, in the Sensor constructor; or 2 in the GetDigitalValue method.
So it's no wonder they always return the same sequence of values.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Dear All, Please kindly help me,
I am using Gridview in C# Windows Application and need your help to solve my issues bellow :
How i can make function in each cell column B which can automatically write words PASS and FAIL with the following Roles:
- First cell in column B : It will automatically write "PASS"
- Second cell in column B : If value in second cell column A less than Value in First cell column A then in second cell column B will Automatically "FAIL" otherwise will "PASS"
- Third cell in column B : If value in third cell column A less than value in First cell column A then in third cell column B will Automatically "FAIL" otherwise will "PASS"
Note : I am not using Database connection for GridView data,
GridView - Google Photos[^]
Sorry for my bad English words, Really appreciate and thanks in advance for help
Thanks,
Deden
modified 8-Feb-18 3:53am.
|
|
|
|
|
|
Use an Event handler for the column A. Whenever a cell's value changes you reset the appropriate cell in column B
|
|
|
|
|
Hi Richard, Thanks a lot for replied,
Actualy This is use for checking Log data from fingerprint device,
Cells on column A in Gridview will automaticaly fill by Log data from finger print,
I need column B to show the result PASS or FAIL
Please advice, Thanks in advance
|
|
|
|
|
Then you need to check which events get fired when the log data information arrives at the view. How is this done automatically?
|
|
|
|