Topic: Columnar block math functions (1 of 19), Read 100 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Monday, February 05, 2007 01:26 PM

From: "Thomas Stafford"

Just spent a little time looking for discussions on Math function Macros and made a couple inquiries but wanted to do more. I am looking for simple Macros which I can load and use without much programming expertise. I know Vedit is not supposed to be Excel but it would be nice to be able to do simple +,-,*,/ on a single blocked column within Vedit with bigger files..300 mb - 1.5 gb


Anyone using Vedit to work with Seismic volumes who have some neat utilities would be appreciated. I am creating pore pressure and effective stress cubes from stacking velocities and working mostly on the PC side and trying to avoid AWK scripts etc.

 


Topic: Columnar block math functions (2 of 19), Read 83 times
Conf: VEDIT Macro Library
From: Fritz Heberlein
Date: Monday, February 05, 2007 02:15 PM

As for additions and subtractions, Scott Lambert wrote a macro called addcol.vdm some years ago. It is still available at his web page:
http://carver.pinc.com/~slambert/macros.htm

Fritz

 


Topic: Columnar block math functions (3 of 19), Read 80 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Monday, June 21, 2010 12:59 AM

On 2/5/2007 2:15:16 PM, Fritz Heberlein wrote:
>As for additions and subtractions, Scott
>Lambert wrote a macro called addcol.vdm
>some years ago. It is still available at
>his web page:
>http://carver.pinc.com/~slambert/macros.
>htm
>
>Fritz


Hi,

I have tried the above url and it no longer works.

At the same time, I was glad to see that Scott posted some recent macros to this forum. So, I am asking him to post
addcol.vdm to this thread.

Thanks Scott,

-peter.

 


Topic: Columnar block math functions (4 of 19), Read 96 times, 1 File Attachment
Conf: VEDIT Macro Library
From: Scott Lambert
Date: Monday, June 21, 2010 11:54 AM


Hi Peter,

I emailed addcol.vdm to your Gmail around the start of June. Sorry you did not get it.

Anyways, addcol.vdm is attached.

Scott

On 6/21/2010 12:59:32 AM, peter rejto wrote:
>At the same time, I was glad to see that
>Scott posted some recent macros to this
>forum. So, I am asking him to post
>addcol.vdm to this thread.
>
>Thanks Scott,
>
>-peter.

 
ADDCOL.VDM (2KB)

 


Topic: Columnar block math functions (5 of 19), Read 102 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Tuesday, June 22, 2010 12:18 PM

Thanks Scott for uploading ADDCOL.VDM again.


When I try to run it from the Vedit Menu, via the usual {Misc, Load/exec user mac ..} command, it runs like a charm.
As it has for so many Vedit users for such a long time.

However, I did not succeed in calling it from another macro.
I have tried the one line macro,


Call_File(10,"|(USER_MACRO)\addcol.vdm")



This one line macro, indeed, loads ADDCOL.VDM into T-reg 10.
However, if I try to execute it via the {Misc, Execute macro ...} command and at the prompt choose T-reg 10, I do not get the right answer in T-reg 0.


I am at a loss and would appreciate the reaction of fellow Vedit users.


Thanks,

-peter

 


Topic: Columnar block math functions (6 of 19), Read 107 times
Conf: VEDIT Macro Library
From: Scott Lambert
Date: Wednesday, June 23, 2010 12:36 PM

Hi Peter,

I am unable to replicate the problem.

Keep in mind, Call_File loads and executes the macro in one command.

Remember to have the numbers highlighted as a block before going misc, execute macro

Scott

On 6/22/2010 12:18:00 PM, peter rejto wrote:
>However, I did not succeed in
>calling it from another macro.
>I have tried the one line
>macro,
>
>
>Call_File(10,"|(USER_MACRO)\ad
>dcol.vdm")
>
>
>
>This one line macro, indeed,
>loads ADDCOL.VDM into T-reg
>10.
>However, if I try to execute
>it via the {Misc, Execute
>macro ...} command and at the
>prompt choose T-reg 10, I do
>not get the right answer in
>T-reg 0.
>
>
>I am at a loss and would
>appreciate the reaction of
>fellow Vedit users.
>
>
>Thanks,
>
>-peter

 


Topic: Columnar block math functions (7 of 19), Read 115 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Wednesday, June 23, 2010 07:45 PM

On 6/23/2010 12:36:24 PM, Scott Lambert wrote:
>Hi Peter,
>
>I am unable to replicate the
>problem.
>

>Remember to have the numbers
>highlighted as a block before
>going misc, execute macro
>
>Scott
>
>On 6/22/2010 12:18:00 PM, peter rejto
>wrote:
>>However, I did not succeed in
>>calling it from another macro.
>>I have tried the one line
>>macro,
>>
>>
>>Call_File(10,"|(USER_MACRO)\ad
>>dcol.vdm")
>>
>>
>>
>>This one line macro, indeed,
>>loads ADDCOL.VDM into T-reg
>>10.
>>However, if I try to execute
>>it via the {Misc, Execute
>>macro ...} command and at the
>>prompt choose T-reg 10, I do
>>not get the right answer in
>>T-reg 0.
>>
>>
>>I am at a loss and would
>>appreciate the reaction of
>>fellow Vedit users.
>>
>>
>>Thanks,
>>
>>-peter
>

Scott,

A big thank you for your highlight suggestion!


In order to avoid such embarrassments in the future, I have added the following informational message to your ADDCOL.VDM macro:

// Check Highlighting
if(block_begin==-1){ Alert Statline_Message("Please Highlight A Columnar Or Linear Block")}
else
{if(block_end==-1){ Alert Statline_Message("Please Highlight A Columnar Or Linear Block")}}
//


Then I tried the adapted macro. In short, it seems to work.
Here are the details: I did try to run the macro in the usual way. That is to say, by loading it into T-reg 100.
First, at purpose, I did not do the highlighting. Then, indeed, I did get my message. Second, I did do the highlighting and used the {Misc, Exute macro...}.
This worked like a charm. That is to say, I got the correct answer in T-reg 0.

In other words, I did succeed in loading and executing the adapted ADDCOL.VDM macro.



I have a hunch that my informational message "reinvents the wheel" In other words, it has been done by fellow Vedit users. I certainly would prefer to take it over and give the appropriate reference.


Now the bottom line: I would like to enhance ADDCOL.VDM to include raws in addition to columns.

Now let me give you a progress report. I learned from Pauli Lindgren, how to convert a raw to a column;

http://webboard.vedit.com?63043,42

Then I can call your ADDCOL.VDM to do the job. Finally, I have to convert columns back to raws.

So, if all goes well, then thanks to Pauli and Scott, we have an ADDRAW.VDM.

My personal preference would be to combine these two macros into an enhanced ADDCOL.VDM macro. What is your personal preference?


I also have a hunch that interchanging raws and columns in your ADDCOL.VDM I should get an ADDRAW.VDM. I tried, but did not succeed. Well I did it and ended up with a macro, which did not give me any error messages. However, it did not give the correct answer either.



Thanks again for the highlight suggestion!


-peter

 


Topic: Columnar block math functions (8 of 19), Read 104 times
Conf: VEDIT Macro Library
From: Scott Lambert
Date: Thursday, June 24, 2010 01:40 PM

Hi Peter,

You are welcome to do what you like with addcol.vdm. It is a 12 year old macro and it probably could be rewritten to take advantage of the new Vedit commands since then. Thank you for asking though. Good luck with addraw.vdm!

Scott

 


Topic: Re: Columnar block math functions (9 of 19), Read 105 times
Conf: VEDIT Macro Library
From: Fritz Heberlein
Date: Thursday, June 24, 2010 01:49 PM

vedit-macros Listmanager schrieb:
addcol.vdm. It is a 12 year old macro

Just for the record: I use it almost every day. Thank you for writing it!


Fritz


--
Akad. Dir. Dr. Friedrich Heberlein
Seminar für Klassische Philologie
der KU Eichstätt-Ingolstadt
85071 Eichstätt
Tel. 08421 931544

 


Topic: Columnar block math functions (10 of 19), Read 106 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Thursday, June 24, 2010 02:52 PM

On 6/24/2010 1:40:32 PM, Scott Lambert wrote:
>Hi Peter,
>Good luck with addraw.vdm!
>
>Scott

Thanks Scott,

As it turned out, one possible version of addrow.vdm is very simple:
Aside from checking the highlighting, here it is:


Replace_Block(",", "|N", Block_Begin, Block_End, ALL)
Call_File(10,"|(USER_MACRO)\Addcol.vdm")


Here, the first line is, of course, a simple adaptation of Pauli's suggestion at

http://webboard.vedit.com?63043,42

There, the suggestion was for sorting a row. In other words, for a different problem.


So, I shall continue to try to make cosmetic changes to Addrow.vdm. Like checking whether or not the highlighted block is a row or column.

I have a hunch that this will require the use of "row column arithmetic via N-registers", pretty much the way you have done it in your Addcol.vdm. In other words, I have a hunch this would be much easier for you to do it then for me.


As Fritz said it, thanks again for writing Addcol.vdm.



-peter

 


Topic: Columnar block math functions (11 of 19), Read 70 times
Conf: VEDIT Macro Library
From: Scott Lambert
Date: Saturday, June 26, 2010 11:57 AM


Hi Peter,

Yes, I can see that a macro that adds a row of numbers would be a good complement to addcol.vdm. One might need a couple of flavours of addrow to cope with the formatting of the numbers, and the separator between the numbers. For Example:

1,234, 2,564, 765, 987, 1,000,000, 2345

or

1234,2564,765,987,1000000,2345

or

1,234 2,564 765 987 1,000,000 2345

Unlike a column of numbers, a row of numbers can come in many different formats, and the macro needs someway to determine where one number ends and the next one begins.

Anyways, such a project will have to wait, as I am currently rewriting my Scribe spell checker macro to correct some flaws of v3.0 and add some new features. Currently on the to do list:

-internal buffer use determined by num_edit_buf

- show context of not found word

- new to way to come up with suggested words, which I hope will be faster

- new automode, where if block is set when Scribe is called, Scribe bypasses the main menu, spell checks the block and then return you to your file. You never see the main menu in this mode. This will help as you won't have to spell check the entire file.

- will handle words with apostrophes better: won't, can't, I'm, you're, etc


I am about 50% done.

Scott

On 6/24/2010 2:52:01 PM, peter rejto wrote:
>So, I shall continue to try to make
>cosmetic changes to Addrow.vdm. Like
>checking whether or not the highlighted
>block is a row or column.
>
>I have a hunch that this will require
>the use of "row column arithmetic via
>N-registers", pretty much the way you
>have done it in your Addcol.vdm. In
>other words, I have a hunch this would
>be much easier for you to do it then for
>me.

 


Topic: Columnar block math functions (12 of 19), Read 68 times, 1 File Attachment
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Saturday, June 26, 2010 02:40 PM

On 6/26/2010 11:57:49 AM, Scott Lambert wrote:
.....>
>Hi Peter,
...>


Thanks Scott,

1.:

>....I am
>currently rewriting my Scribe
>spell checker macro to correct
>some flaws of v3.0 and add
>some new features.


I was glad to learn that you are working on Scribe.
Since I like to know what is under the hood, and since your original
scribe used only Vedit, I learned quite a bit from it. (This is why I
also like some programs that "reinvent the wheel".)


2.:

>On 6/24/2010 2:52:01 PM, peter rejto
>wrote:
>>So, I shall continue to try to make
>>cosmetic changes to Addrow.vdm. Like
>>checking whether or not the highlighted
>>block is a row or column.
>>
>>I have a hunch that this will require
>>the use of "row column arithmetic via
>>N-registers", pretty much the way you
>>have done it in your Addcol.vdm. In
>>other words, I have a hunch this would
>>be much easier for you to do it then for
>>me.

I am going to upload a preliminary version of my macro to this message.

3.:

>Yes, I can see that a macro
>that adds a row of numbers
>would be a good complement to
>addcol.vdm.


I really appreciate your comments on adding rows!
At the same time, I am suggesting to start a new thread
with this topic.



-peter

 
Edited version of Scott's ADDCOL.VDM

 


Topic: Columnar block math functions (13 of 19), Read 28 times
Conf: VEDIT Macro Library
From: Pauli Lindgren
Date: Sunday, June 27, 2010 08:27 AM

On 6/24/2010 2:52:01 PM, peter rejto wrote:
>
>As it turned out, one possible version of addrow.vdm is very simple:
>Aside from checking the highlighting, here it is:
>
>Replace_Block(",", "|N", Block_Begin,
>Block_End, ALL)
>Call_File(10,"|(USER_MACRO)\Addcol.vdm")

One problem with that is that you are modifying the the original file, which is not good. (And the file may be read-only.) At least you should copy the row into a temporary buffer.

In addition, that implementation only works if comma is used as a separator and there are no commas used as thousands separator.

I think a better way is to use the code from addcol.vdm but use some other separator instead of newline. In practice, the user should be able to choose the separators.
However, one option could be to use any character other than number, decimal point or '-' as a separator.

--
Pauli

 


Topic: Columnar block math functions (14 of 19), Read 27 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Sunday, June 27, 2010 01:30 PM

On 6/27/2010 8:27:03 AM, Pauli Lindgren wrote:
>On 6/24/2010 2:52:01 PM, peter rejto
>wrote:
>>
>>As it turned out, one possible version of addrow.vdm is very simple:
>>Aside from checking the highlighting, here it is:
>>
>>Replace_Block(",", "|N", Block_Begin,
>>Block_End, ALL)
>>Call_File(10,"|(USER_MACRO)\Addcol.vdm")
>



>--
>Pauli

Thanks Pauli,

1.:

>In practice, the user should be able to
>choose the separators.



The user should put this separator into a T-register. Then, I shall replace the content of this T-register by the new line symbol "|N". At the same time, for personal reasons I shall choose the default value of this T-register to be the comma.


2.:

>..., that implementation only
>works if comma is used as a separator
>and there are no commas used as
>thousands separator.
>

I did overlook this fact. In fact, I learned about it from Scott's previous message. (In other words, I made the hidden assumption that there are no thousand separators.)
(I shall also check the way Excel saves a spreadsheet in .CSV format if comma is used as a thousand separator.)


3.:


>...read-only


I was not working with read-only files. In fact, I was glad to see the block markers have been removed and the block has been transposed. It reassured me that the macro did work. Now I have additional messages on the Statline and so, I no longer need these reassurances.
I think I can handle this.


NOW COMES THE HARD PART.


4.:

>I think a better way is to use the code
>from addcol.vdm but use some other
>separator instead of newline.
>However, one option could be to use any
>character other than number, decimal
>point or '-' as a separator.
>


I believe that I have been thinking along similar lines but got stock.

So, I did it on a stylistic level. Lines and columns are symmetrical in the cur_line and cur_col commands and in the user manual. So I tried to find the part of ADDCOL.VDM where this symmetry is broken. But could not find it.

I also tried to run the macro for a highlighted line_block
in place of a highlighted columnar_block macro. It did not work, so the macro is not symmetrical in lines and columns.

I made a small progress in my ADDCOL_2.VDM that I have recently uploaded. There I could move some of Scotts cur_line, cur_col arithmetic to my Checking section. This is progress, inasmuch as, I have to find this symmetry breaking in a smaller program.


In short, I am missing something basic and I would appreciate additional help.

Incidentally, your previous comments to my sort questions and your rosettastone sort reference were very helpful.
They showed me that many properties of the sort command are independent of columns and lines. I have a hunch that I am fighting this issue again.



-peter

 


Topic: Columnar block math functions (15 of 19), Read 26 times
Conf: VEDIT Macro Library
From: Scott Lambert
Date: Monday, June 28, 2010 02:18 PM


Hi Peter,

I can't find your message about dividing 1 by 3, so...

Here is how to get 1 divided by 3 in Vedit

#10=1
#11=3
#12=#10*1000
#12=#12/#11
numstr(#12,12)
reg_set(12,".",insert)

T-Reg 12 now holds the correct answer to 3 decimal points (want 2 ? use 100 instead of a 1000)

Unfortunately, you can do no calculations with the answer in t-reg 12

However if you remember the number in #12 is 1000 times its actual value, you can do calculations with that number and then adjust the decimal point at the end.

For example adding more to the above code:

#13=64
#14=#13*#12
#14=#14/1000 // adjusting decimal point

Again #14 holds the right answer.

Scott

 


Topic: Re: Columnar block math functions (16 of 19), Read 19 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Monday, June 28, 2010 03:53 PM

On 28.06.2010 20:18 in vedit-macros Scott Lambert wrote:
>
> Here is how to get 1 divided by 3 in Vedit
>
> #10=1
> #11=3
> #12=#10*1000
> #12=#12/#11
> numstr(#12,12)
> reg_set(12,".",insert)


Some years ago I wrote macros for floating point mathematics in Vedit.

I can't remember the details, but they are here:
http://www.ziemski.net/vedit/programming.html in "(Group: VDM -
mathematics)"
e.g. http://www.ziemski.net/vedit/macros/floatmath.vdm


Christian

 


Topic: Re: Columnar block math functions (17 of 19), Read 23 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Monday, June 28, 2010 04:38 PM

PS:
Regarding floating point calculations there have been some discussions here.

http://webboard.vedit.com/read?13972,29

Topic: Floating point math within Vedit
Conf: VEDIT Macro Library
Date: Friday, February 28, 2003 06:56 PM


http://webboard.vedit.com/read?13571,30e#13571

Topic: Simple math using N-registers
Conf: VEDIT Macro Language Support
Date: Monday, April 16, 2001 07:56 AM


Christian

 


Topic: Re: Columnar block math functions (19 of 19), Read 21 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Tuesday, June 29, 2010 01:20 PM

On 6/28/2010 4:38:41 PM, Christian Ziemski wrote:
>PS:
>Regarding floating point
>calculations there have been
>some discussions here.
>
>http://webboard.vedit.com/read
>?13972,29
>
>Topic: Floating point math
>within Vedit
>Conf: VEDIT Macro Library
>Date: Friday, February 28,
>2003 06:56 PM
>
>

>http://webboard.vedit.com/read
>?13571,30e#13571
>
>Topic: Simple math using
>N-registers
>Conf: VEDIT Macro Language
>Support
>Date: Monday, April 16, 2001
>07:56 AM
>
>
>Christian


Thanks Christian for these references.

So, I have learned from Ted's message the Vedit can handle about ten digits and Vedit 64 can handle about twice as much.


Now,I have to tell you that the floating point part of the discussions were above my head. So, I read them for style and not content.

I have a hunch that the floating point issue would allow one to address the delicate question of rounding. In other words, it would allow one to estimate the error that Vedit makes in the process of doing such calculations.

-peter

 


Topic: Columnar block math functions (18 of 19), Read 32 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Tuesday, June 29, 2010 01:08 PM

On 6/28/2010 2:18:00 PM, Scott Lambert wrote:
>
>Hi Peter,
>
>I can't find your message
>about dividing 1 by 3, so...
>
>Here is how to get 1 divided
>by 3 in Vedit
>
>#10=1
>#11=3
>#12=#10*1000
>#12=#12/#11
>numstr(#12,12)
>reg_set(12,".",insert)
>
>T-Reg 12 now holds the correct
>answer to 3 decimal points
>(want 2 ? use 100 instead of a
>1000)
>
>Unfortunately, you can do no
>calculations with the answer
>in t-reg 12
>
>However if you remember the
>number in #12 is 1000 times
>its actual value, you can do
>calculations with that number
>and then adjust the decimal
>point at the end.
>
>For example adding more to the
>above code:
>
>#13=64
>#14=#13*#12
>#14=#14/1000 // adjusting
>decimal point
>
>Again #14 holds the right
>answer.
>
>Scott
>

Thanks Scott for this explanation.
So, I can go back to ADDCOL.VDM and look for this type of calculations there.

Now I would like to ask another question:
Since computers do their calculations in binary system, instead of multiplying by a power of ten, I would multiply by a power of two. I was trying to find in the Vedit Macro manual how to do this but could not. The closest I came up with was the left shift. For example

entering #1=2<<30

Vedit gave me 2^31.

I know that you are busy with scribe, so I would appreciate it if other Vedit users might look into.


I have a hunch that using binary system instead of the decimal system might make it easier to estimate the error that Vedit makes when it calculates 1/3. I also have a hunch that this error estimate is closely related to the "ROUNDING" question.

In any case, I was glad to see the No rounding WARNING in ADDCOL.VDM. In other words, I was glad to see it emphasized that rounding and addition are seperate issues.


Now a related rounding issue. I looked up in the Macro Language manual the definition of an Integer. It said that it is a number in the range 0, xxx where, xxx was a ten digit number and the first nine digits were the same as the one of 2<<30, supplied by Vedit. In other words, there is a discrepancy in the tenth digit.


-peter