Scientific Programming
153 subscribers
158 photos
30 videos
138 files
442 links
Tutorials and applications from scientific programming

https://github.com/Ziaeemehr
Download Telegram
Scientific Programming
Still working on it, including Python scripts to reproduce some of the figures in the book. GitHub
یه جلسه همخوانی برای مطالعه این کتاب برقراره و تا سه شنبه ۱۵ مرداد مهلت ثبت نام داره.
ویدیو جلسات هم ظبط میشه.
https://t.me/SystemBiologystudygroup
Forwarded from RSG - Iran
📍"نقشه‌ی راه دومین باهم‌خوانی شاخه‌ی دانشجویی انجمن جهانی زیست‌شناسی محاسباتی در ایران"

از جذابیت‌های دیگر این دوره:

۱) مشارکت و کار تیمی تمامی شرکت‌کنندگان در ایجاد فایل مخصوص هر فصل حاوی لینک ویدئوهای مرتبط و سایر منابع تکمیل‌کننده‌ی بحث

۲) تلاش برای دعوت از متخصصانی فرهیخته در برخی از جلسات برای بهره‌مندی از دانش ارزشمند ایشان

۳) یادگیری ترفندهای جذاب و کاربردی از متخصصین

۴) یادگیری اجرای پروژه‌های پایه

۵) در پایان دوره برای افرادی که در بیش از ۸۰ درصد جلسات حضور فعال داشته باشند گواهی صادر می‌گردد.

🔗لینک ثبت نام

🔗لینک دانلود کتاب Network Science
🔗لینک دانلود کتاب Systems Biology

🔗لینک مخصوص داوطلبان ارائه


🚀Telegram
🖼LinkedIn
🖼Instagram

#باهم‌خوانی
Please open Telegram to view this post
VIEW IN TELEGRAM
GPU monitor


pip install nvitop


GitHub

Related posts:
https://t.me/scientific_programming/653
👍3
# C++ Data Structures

(Landscape view shows better)
A detailed map of C++ data structures based on the latest updates, including both standard data structures from the Standard Template Library (STL) and newer features introduced in C++17, C++20, and C++23.

## 1. Primitive Data Types

- int
- char
- float
- double
- bool
- wchar_t (wide character type)
- char16_t, char32_t (introduced in C++11 for UTF-16 and UTF-32 encoding)

## 2. Compound Data Types

### Arrays

- Static: int arr[10];
- Dynamic: int* arr = new int[10];

### Pointers

- int* ptr;
- std::unique_ptr, std::shared_ptr, std::weak_ptr (introduced in C++11 for smart pointers)

### References

- int& ref = x;

## 3. Standard Containers (STL)

### Sequence Containers

- std::array (fixed-size array, introduced in C++11)
- std::vector (dynamic array)
- std::deque (double-ended queue)
- std::list (doubly linked list)
- std::forward_list (singly linked list, introduced in C++11)

### Container Adaptors

- std::stack (LIFO data structure, built on top of other containers)
- std::queue (FIFO data structure)
- std::priority_queue (heap data structure)

### Associative Containers

- std::set (ordered set)
- std::multiset (allows duplicate elements)
- std::map (key-value pairs, ordered by keys)
- std::multimap (allows duplicate keys)

### Unordered Containers (introduced in C++11)

- std::unordered_set (hash table-based set)
- std::unordered_multiset
- std::unordered_map (hash table-based key-value pairs)
- std::unordered_multimap

## 4. String Handling

### Basic Strings

- std::string (dynamic string of characters)
- std::wstring (wide string)
- std::u16string, std::u32string (for UTF-16 and UTF-32 encoding)

### String Views (introduced in C++17)

- std::string_view (lightweight, non-owning string reference)
- std::wstring_view, std::u16string_view, std::u32string_view

## 5. Iterators

### Types

- Input iterators
- Output iterators
- Forward iterators
- Bidirectional iterators
- Random-access iterators

### Iterator Adapters

- std::reverse_iterator
- std::move_iterator
- std::insert_iterator, std::back_insert_iterator, std::front_insert_iterator

### Range-based for loops (introduced in C++11)

- for (auto& item : container)

## 6. Utility Classes

### Pairs and Tuples

- std::pair
- std::tuple (introduced in C++11)
- Structured bindings (introduced in C++17): auto [x, y] = pair;

### Optional (introduced in C++17)

- std::optional<T>: stores an optional value.

### Variant (introduced in C++17)

- std::variant<Ts...>: type-safe union of multiple types.

### Any (introduced in C++17)

- std::any: holds any type of value.

## 7. Algorithms

### Sorting Algorithms

- std::sort, std::stable_sort
- std::partial_sort, std::nth_element
- std::is_sorted

### Searching Algorithms

- std::find, std::binary_search
- std::find_if, std::find_if_not

### Set Operations

- std::set_union, std::set_difference

### Other Algorithms

- std::transform, std::for_each, std::accumulate

## 8. Concurrency (C++11 and beyond)

### Thread Support

- std::thread (multi-threading support)
- std::mutex, std::shared_mutex (introduced in C++17)
- std::lock_guard, std::unique_lock

### Futures and Promises

- std::future, std::promise, std::async

### Coroutines (introduced in C++20)

- co_await, co_yield, co_return

## 9. Ranges (Introduced in C++20)

Provides a new way to handle ranges of data, offering a more modern alternative to traditional iterator-based algorithms.

- std::ranges::begin(), std::ranges::end()
- std::views::filter, std::views::transform

## 10. Concepts (Introduced in C++20)

Used to specify the requirements on template arguments, making template code easier to write and understand.

- template<typename T> requires std::integral<T>

## 11. Smart Pointers

### Ownership Models
- std::unique_ptr: Exclusive ownership of an object.
- std::shared_ptr: Shared ownership of an object.
- std::weak_ptr: Weak reference to a shared pointer, preventing circular dependencies.

## 12. Custom Data Structures

### Class/Struct

- class MyClass { /* ... */ };
- struct MyStruct { /* ... */ };

### Union

- union MyUnion { /* ... */ }

Search for CPP to find related posts, also practicing each section is a proper method to improve the programming skills in C++.
# Python Data Structures

## 1. Primitive Data Types
- int: Integer values.

  x = 10

float: Floating-point numbers.

y = 10.5

bool: Boolean values (True/False).

z = True

str: Strings (immutable sequences of Unicode characters).

s = "Hello, World!"


2. Sequence Types

a. List

A mutable, ordered collection of elements.

lst = [1, 2, 3, 4]
lst.append(5)


b. Tuple

An immutable, ordered collection of elements.

tpl = (1, 2, 3)


c. Range

A sequence of numbers, often used in loops.

r = range(1, 10)


d. String

A sequence of characters, treated as a list of characters.

s = "Hello"
first_char = s[0]


e. Byte/Bytearray

Immutable (bytes) or mutable (bytearray) sequences of bytes.

b = bytes([65, 66, 67])  # A, B, C
ba = bytearray([65, 66, 67])


3. Set Types

a. Set

An unordered, mutable collection of unique elements.

s = {1, 2, 3, 4}
s.add(5)


b. Frozen Set

An immutable version of a set.

fs = frozenset([1, 2, 3])

4. Mapping Type

Dictionary

An unordered, mutable collection of key-value pairs.

d = {'name': 'Alice', 'age': 25}
d['location'] = 'Wonderland'

5. Specialized Data Structures

a. Deque (Double-Ended Queue)

A thread-safe, general-purpose, double-ended queue.

from collections import deque
dq = deque([1, 2, 3])
dq.appendleft(0)


b. Defaultdict

A dictionary that provides a default value for non-existent keys.

from collections import defaultdict
dd = defaultdict(int)
dd['a'] += 1 # If 'a' doesn't exist, its value will default to 0

c. OrderedDict

A dictionary that remembers the order of key insertions (introduced in Python 3.1).

from collections import OrderedDict
od = OrderedDict()
od['a'] = 1
od['b'] = 2


6. Stack and Queue

a. Stack (List-based)

A last-in, first-out (LIFO) structure.

stack = []
stack.append(10)
stack.pop()

b. Queue (List or deque-based)

A first-in, first-out (FIFO) structure.

queue = deque()
queue.append(10)
queue.popleft()
7. Linked List

Python doesn't have a built-in linked list, but you can implement one using classes.

# Node class to represent a single node in the linked list
class Node:
def __init__(self, data):
self.data = data # Data held by the node
self.next = None # Pointer to the next node in the list

# LinkedList class to manage the linked list
class LinkedList:
def __init__(self):
self.head = None # Initialize the head of the list as None

# Method to append a new node to the end of the list
def append(self, data):
new_node = Node(data) # Create a new node with the given data
if self.head is None:
self.head = new_node # If the list is empty, set the new node as the head
return
last = self.head
while last.next: # Traverse to the end of the list
last = last.next
last.next = new_node # Set the next of the last node to the new node

# Method to print the linked list
def print_list(self):
current = self.head
while current:
print(current.data, end=" -> ")
current = current.next
print("None")

# Method to delete the first occurrence of a node with the given data
def delete(self, data):
current = self.head

# If the head node holds the data to be deleted
if current and current.data == data:
self.head = current.next # Change the head to the next node
current = None # Free the old head node
return

# Search for the node to be deleted, keeping track of the previous node
prev = None
while current and current.data != data:
prev = current
current = current.next

# If the data was not present in the list
if current is None:
print("Node not found in the list.")
return

# Unlink the node from the list
prev.next = current.next
current = None

# Example usage:
if __name__ == "__main__":
# Create a linked list
linked_list = LinkedList()

# Append some elements to the list
linked_list.append(1)
linked_list.append(2)
linked_list.append(3)

# Print the list
print("Original Linked List:")
linked_list.print_list()

# Delete a node
linked_list.delete(2)

# Print the list after deletion
print("Linked List after deleting 2:")
linked_list.print_list()

8. Heap (Priority Queue)

Python’s heapq module implements a binary heap.

import heapq
heap = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]
heapq.heapify(heap)
smallest = heapq.heappop(heap)
9. Tree (Binary Tree Example)

Python doesn't have built-in tree structures, but you can implement one using classes.

# Node class for a binary tree
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None

# Function to perform an in-order traversal (left, root, right)
def inorder(root):
if root:
inorder(root.left)
print(root.data, end=" ")
inorder(root.right)

# Example usage:
if __name__ == "__main__":
# Create the binary tree
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)
root.left.right = Node(5)

# In-order traversal
inorder(root)


10. Graph (Adjacency List Example)

You can use dictionaries or lists to represent graphs in Python.

graph = {
'A': ['B', 'C'],
'B': ['A', 'D', 'E'],
'C': ['A', 'F'],
'D': ['B'],
'E': ['B', 'F'],
'F': ['C', 'E']
}
Synchronizing Numba and NumPy RNG States for Consistent Behavior

The Numba RNG state and NumPy RNG states are entirely separate. Therefore calling np.random.seed() will only impact the NumPy RNG seed and this explains the behaviour in the above. To make Numba's RNG state the same as NumPy's, the np.random.seed() function needs calling from within a JIT compiled region, for example:

python
import numpy as np
from numba import jit
from numba.extending import register_jitable

@register_jitable # This will run in JIT mode only if called from a JIT function
def set_seed_compat(x):
np.random.seed(x)


@jit(nopython=True)
def get_random():
set_seed_compat(42)
print(np.random.rand(3))

def get_radnom2():
print(np.random.rand(3))

get_random()
get_random.py_func()
get_radnom2()

#[0.37454012 0.95071431 0.73199394]
#[0.37454012 0.95071431 0.73199394]
#[0.59865848 0.15601864 0.15599452]
The third should be different, but still repeatable by re-execution of the script.
# Introduction to Python Package with C++ Integration

I am sharing a demo Python package that demonstrates the integration of C++ code using SWIG (Simplified Wrapper and Interface Generator). This project allows users to leverage the performance advantages of C++ while utilizing the simplicity of Python.

## Key Features

- C++ Integration: The package includes C++ code wrapped with SWIG, facilitating efficient function calls from Python.
- Easy Installation: I've prepared both pyproject.toml and setup.py files to enable seamless C++ code compilation during pip installation. The package also automatically detects and compiles any additional C++ modules, eliminating the need for manual configuration changes.
- Cross-Platform Compatibility: Designed for compatibility across different platforms, this package can be installed and run without compatibility issues.

Github

Medium
NVIDIA CUDA Virtual Connect With Experts Event Information

We are starting a monthly virtual event where CUDA enthusiasts can connect directly with a panel of real-life CUDA developers at NVIDIA. This is a chance to meet some of the people designing and implementing your favorite CUDA drivers, kernels, libraries and tools; and ask questions related to your project or work.

Event Information:

When?

Friday, September 27, 2024 at 10-11:30am PT

What?

This month, we will be discussing the CUDA Python ecosystem. You will have the opportunity to ask questions via chat about topics like CuPy, Numba, and other Python libraries to our LIVE panel of CUDA Python experts.

Who can Attend?

CUDA and Python developers of all levels and backgrounds.

Where?

Join us on NVIDIA’s Microsoft Teams Instance here
👍1
How AI is Changing Coding and Education
FREE STANFORD WEBINAR

October 9, 2024 | 11:00-11:45 am PT

Registration
Installing Lama locally
Video
https://ollama.com/library/llama3.2


bash
sudo ufw allow 1143/tcp
curl -fsSL https://ollama.com/install.sh | sh

# v3.1, 8billions parameters
ollama pull llama3.1:8b
ollama run llama3.1
# v3.2, 3 billions parameters
ollama pull llama3.2
ollama run llama3.2
# http://127.0.0.1:11434/ to check ollama is working