DIYbanter

DIYbanter (https://www.diybanter.com/)
-   Electronic Schematics (https://www.diybanter.com/electronic-schematics/)
-   -   "Algebraic" IF Statement Evaluation (https://www.diybanter.com/electronic-schematics/278321-algebraic-if-statement-evaluation.html)

Jim Thompson May 19th 09 05:19 PM

"Algebraic" IF Statement Evaluation
 
I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona 85048 Skype: Contacts Only | |
| Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
| E-mail Icon at http://www.analog-innovations.com | 1962 |

"When the government fears the People, that is Liberty.
When the People fear the Government, that is Tyranny."
- attributed to Thomas Jefferson by his contemporaries

"The Constitution is not an instrument for the government to
restrain the people, it is an instrument for the people to
restrain the government -- lest it come to dominate our lives and
interests." - Patrick Henry

[email protected] May 19th 09 05:53 PM

"Algebraic" IF Statement Evaluation
 
On Tue, 19 May 2009 09:19:33 -0700, Jim Thompson
wrote:

I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson


X=int(V11/7)
X/X

[email protected] May 19th 09 05:56 PM

"Algebraic" IF Statement Evaluation
 
On Tue, 19 May 2009 09:19:33 -0700, Jim Thompson
wrote:

I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson


gah!
messed that up :S


[email protected] May 19th 09 06:03 PM

"Algebraic" IF Statement Evaluation
 
On Tue, 19 May 2009 10:53:47 -0600, wrote:

On Tue, 19 May 2009 09:19:33 -0700, Jim Thompson
wrote:

I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson


X=int(V11/7)
X/X

t=X/X

This will sorta work, but if x is 0 then you'll probably get errors,
to a human it's the 0/0 = 1 thing not having used your emulator I
can't be sure what'll happen of how to treat an error like this.



Jim Thompson May 19th 09 06:06 PM

"Algebraic" IF Statement Evaluation
 
On Tue, 19 May 2009 11:03:32 -0600, wrote:

On Tue, 19 May 2009 10:53:47 -0600,
wrote:

On Tue, 19 May 2009 09:19:33 -0700, Jim Thompson
wrote:

I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson


X=int(V11/7)
X/X

t=X/X

This will sorta work, but if x is 0 then you'll probably get errors,
to a human it's the 0/0 = 1 thing not having used your emulator I
can't be sure what'll happen of how to treat an error like this.



I don't have INT available, I do have ABS and some trig functions

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona 85048 Skype: Contacts Only | |
| Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
| E-mail Icon at
http://www.analog-innovations.com | 1962 |

Stormy on the East Coast today... due to Bush's failed policies.

Paul Hovnanian P.E. May 19th 09 06:43 PM

"Algebraic" IF Statement Evaluation
 
Jim Thompson wrote:

I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson


Do you have a unit step function (u(x)) available?

--
Paul Hovnanian
----------------------------------------------------------------------
Have gnu, will travel.

Jim Thompson May 19th 09 06:49 PM

"Algebraic" IF Statement Evaluation
 
On Tue, 19 May 2009 13:49:46 -0400, Spehro Pefhany
wrote:

On Tue, 19 May 2009 09:19:33 -0700, Jim Thompson
wrote:

I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson


(1+sgn(V11-7))/2 ?


I don't have function SGN :-(

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona 85048 Skype: Contacts Only | |
| Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
| E-mail Icon at http://www.analog-innovations.com | 1962 |

Stormy on the East Coast today... due to Bush's failed policies.

Spehro Pefhany May 19th 09 06:49 PM

"Algebraic" IF Statement Evaluation
 
On Tue, 19 May 2009 09:19:33 -0700, Jim Thompson
wrote:

I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson


(1+sgn(V11-7))/2 ?



Spehro Pefhany May 19th 09 07:03 PM

"Algebraic" IF Statement Evaluation
 
On Tue, 19 May 2009 10:06:34 -0700, Jim Thompson
wrote:

On Tue, 19 May 2009 11:03:32 -0600, wrote:

On Tue, 19 May 2009 10:53:47 -0600,
wrote:

On Tue, 19 May 2009 09:19:33 -0700, Jim Thompson
wrote:

I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson

X=int(V11/7)
X/X

t=X/X

This will sorta work, but if x is 0 then you'll probably get errors,
to a human it's the 0/0 = 1 thing not having used your emulator I
can't be sure what'll happen of how to treat an error like this.



I don't have INT available, I do have ABS and some trig functions

...Jim Thompson



y = V11 -7

(abs(y) + y)/(2*y)



Spehro Pefhany May 19th 09 08:50 PM

"Algebraic" IF Statement Evaluation
 
On Tue, 19 May 2009 14:03:08 -0400, Spehro Pefhany
wrote:

On Tue, 19 May 2009 10:06:34 -0700, Jim Thompson
wrote:

On Tue, 19 May 2009 11:03:32 -0600, wrote:

On Tue, 19 May 2009 10:53:47 -0600,
wrote:

On Tue, 19 May 2009 09:19:33 -0700, Jim Thompson
wrote:

I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson

X=int(V11/7)
X/X
t=X/X

This will sorta work, but if x is 0 then you'll probably get errors,
to a human it's the 0/0 = 1 thing not having used your emulator I
can't be sure what'll happen of how to treat an error like this.



I don't have INT available, I do have ABS and some trig functions

...Jim Thompson



y = V11 -7

(abs(y) + y)/(2*y)


P.S. If you want avoid awkward situations very near y == 0 you could
do

(abs(y) + y)/(2* abs(y) + e)

where e is a very small positive number


Jasen Betts[_2_] May 20th 09 12:38 PM

"Algebraic" IF Statement Evaluation
 
On 2009-05-19, Jim Thompson wrote:
I need to evaluate...

IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
t may be something like V11 = 7, for example)

BUT I have no IF statement handling capability at this level of a
simulation.

I do have algebraic capability.

Is there some cute way to do this algebraically?

...Jim Thompson


are there any operators or functions that can give a different
mumeric result depending on the truth of the input.

many systems have false as 0 and true as 1 (or less common -1)



else maybe something like (sgn( sgn(V11-7) *2 +1 ) + 1 ) /2

Tom Del Rosso[_3_] May 21st 09 12:09 AM

"Algebraic" IF Statement Evaluation
 

Jim Thompson wrote:

I don't have INT available, I do have ABS and some trig functions


ABS has an intrinsic "if" that can do it. Spehro showed the method.




All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2014 DIYbanter