mirror of
https://github.com/RustyRaptor/ProgrammingLanguages.git
synced 2026-12-03 21:55:15 -07:00
copied code from previous lab with some
modifications.
This commit is contained in:
1 parent
45b0917004
commit
27edc3339c
7 files changed
+6393
No files matched your search
@@ -0,0 +1,6 @@
|
||||
*.o
|
||||
*.mod
|
||||
gaussian_elimination
|
||||
matrix.txt
|
||||
test.txt
|
||||
.ipynb_checkpoints
|
||||
@@ -0,0 +1,27 @@
|
||||
FC = gfortran -std=gnu
|
||||
SRC = gaussian_elimination.f90
|
||||
EXEC = gaussian_elimination
|
||||
MODULE = string_to_real.mod
|
||||
MODF = string_to_real.f90
|
||||
RM = rm -f
|
||||
OBJMAIN = gaussian_elimination.o
|
||||
OBJMOD = string_to_real.o
|
||||
|
||||
# Variables so its easy to make changes if I need to (it ended up being helpful)
|
||||
|
||||
all: $(EXEC)
|
||||
|
||||
$(EXEC): $(SRC) $(MODULE) $(OBJMOD) $(OBJMAIN)
|
||||
$(FC) $(OBJMOD) $(OBJMAIN) -o $(EXEC)
|
||||
|
||||
$(OBJMAIN): $(SRC)
|
||||
$(FC) -c $(SRC)
|
||||
|
||||
$(MODULE): $(MODF)
|
||||
$(FC) -c $(MODF)
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJMAIN) $(OBJMOD) $(MODULE) $(EXEC)
|
||||
|
||||
test: clean $(EXEC)
|
||||
./$(EXEC) 3 4 "matrix.txt"
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
## Usage
|
||||
|
||||
### Testing the fortran code
|
||||
1. Clean, build, and run
|
||||
2. (needs a file matrix.txt containing 12 reals separated by spaces)
|
||||
```bash
|
||||
make test
|
||||
```
|
||||
|
||||
3. build
|
||||
```bash
|
||||
make
|
||||
```
|
||||
|
||||
4. Clean binaries
|
||||
```
|
||||
make clean
|
||||
```
|
||||
|
||||
### Executing The python notebook
|
||||
1. Install requirements
|
||||
2. It's recommended to use a virtualenv
|
||||
3. `pip install -r requirements.txt`
|
||||
4. Now you can open the notebook in software that supports it.
|
||||
5. You can run jupyter like this
|
||||
1. `jupyter notebook`
|
||||
2. alternatively you can use the full lab
|
||||
1. `jupyter-lab`
|
||||
6. now select `compiled_vs_interpreted.ipynb` in the browser
|
||||
7. Just click "run all" its usually a double play sign.
|
||||
8. The notebook also builds and executes the fortran code
|
||||
Whitespace-only changes.
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,18 @@
|
||||
# Report
|
||||
## Ziad Arafat
|
||||
### 02/21/2023
|
||||
### Programming Languages PA 2
|
||||
|
||||
In our code, we utilized a function call after an `AND` operator to determine whether or not short-circuit evaluation is used in a given programming language. If the language uses short-circuit evaluation, the `print_answer()` function will not be executed and the output will be "`If you only see this then we DO have short circuit evaluation`". However, if the language does not use short-circuit evaluation, the `print_answer()` function will be executed and the output will be "`We DO NOT have short-circuit evaluation!`" followed by "`If you only see this then we DO have short circuit evaluation`". By placing `print_answer()` as the second operand in the `AND` expression, we took advantage of the fact that the second operand will only be evaluated if the first operand is true. In this way, we were able to determine whether or not short-circuit evaluation is used in a given programming language.
|
||||
|
||||
|
||||
| Language | Short-Circuit? | Output |
|
||||
| -------- | -------------- | ------------------------------------- |
|
||||
| Ada | No | We DO NOT have short-circuit evaluation! If you only see this then we DO have short circuit evaluation| |
|
||||
| Bash | Yes | If you only see this then we DO have short circuit evaluation |
|
||||
| Perl | Yes | If you only see this then we DO have short circuit evaluation |
|
||||
| PHP | Yes | If you only see this then we DO have short circuit evaluation|
|
||||
|
||||
In the Ada example, we're using the `AND` operator and `print_answer` function, but it does not demonstrate short-circuit evaluation since the second operand will always be evaluated in Ada. I think it's worth noting that Ada does have an additional operator called `AND then` which does have short circuit evaluation.
|
||||
|
||||
In the Bash, Perl, and PHP examples, we are using the `&&` operator, which demonstrates short-circuit evaluation. The `print_answer` function is only called if the first operand is true, which allows the code to avoid unnecessary evaluations of the second operand if it is not needed to determine the result of the expression.
|
||||
@@ -0,0 +1,5 @@
|
||||
# numpy==1.24.2
|
||||
# scipy==1.10.1
|
||||
# jupyter
|
||||
# jupyterlab
|
||||
# plotly
|
||||
Reference in new issue
Block a user