text:
# AUTO GENERATED FILE - DO NOT EDIT

export dcc_datepickersingle

"""
    dcc_datepickersingle(;kwargs...)

A DatePickerSingle component.
DatePickerSingle is a tailor made component designed for selecting
a single day off of a calendar.

The DatePicker integrates well with the Python datetime module with the
startDate and endDate being returned in a string format suitable for
creating datetime objects.

This component is based off of Airbnb's react-dates react component
which can be found here: https://github.com/airbnb/react-dates
Keyword arguments:
- `id` (String; optional): The ID of this component, used to identify dash components
in callbacks. The ID needs to be unique across all of the
components in an app.
- `date` (String; optional): Specifies the starting date for the component, best practice is to pass
value via datetime object
- `min_date_allowed` (String; optional): Specifies the lowest selectable date for the component.
Accepts datetime.datetime objects or strings
in the format 'YYYY-MM-DD'
- `max_date_allowed` (String; optional): Specifies the highest selectable date for the component.
Accepts datetime.datetime objects or strings
in the format 'YYYY-MM-DD'
- `initial_visible_month` (String; optional): Specifies the month that is initially presented when the user
opens the calendar. Accepts datetime.datetime objects or strings
in the format 'YYYY-MM-DD'
- `day_size` (Real; optional): Size of rendered calendar days, higher number
means bigger day size and larger calendar overall
- `calendar_orientation` (a value equal to: 'vertical', 'horizontal'; optional): Orientation of calendar, either vertical or horizontal.
Valid options are 'vertical' or 'horizontal'.
- `is_RTL` (Bool; optional): Determines whether the calendar and days operate
from left to right or from right to left
- `placeholder` (String; optional): Text that will be displayed in the input
box of the date picker when no date is selected.
Default value is 'Start Date'
- `reopen_calendar_on_clear` (Bool; optional): If True, the calendar will automatically open when cleared
- `number_of_months_shown` (Real; optional): Number of calendar months that are shown when calendar is opened
- `with_portal` (Bool; optional): If True, calendar will open in a screen overlay portal,
not supported on vertical calendar
- `with_full_screen_portal` (Bool; optional): If True, calendar will open in a full screen overlay portal, will
take precedent over 'withPortal' if both are set to True,
not supported on vertical calendar
- `first_day_of_week` (a value equal to: 0, 1, 2, 3, 4, 5, 6; optional): Specifies what day is the first day of the week, values must be
from [0, ..., 6] with 0 denoting Sunday and 6 denoting Saturday
- `stay_open_on_select` (Bool; optional): If True the calendar will not close when the user has selected a value
and will wait until the user clicks off the calendar
- `show_outside_days` (Bool; optional): If True the calendar will display days that rollover into
the next month
- `month_format` (String; optional): Specifies the format that the month will be displayed in the calendar,
valid formats are variations of "MM YY". For example:
"MM YY" renders as '05 97' for May 1997
"MMMM, YYYY" renders as 'May, 1997' for May 1997
"MMM, YY" renders as 'Sep, 97' for September 1997
- `display_format` (String; optional): Specifies the format that the selected dates will be displayed
valid formats are variations of "MM YY DD". For example:
"MM YY DD" renders as '05 10 97' for May 10th 1997
"MMMM, YY" renders as 'May, 1997' for May 10th 1997
"M, D, YYYY" renders as '07, 10, 1997' for September 10th 1997
"MMMM" renders as 'May' for May 10 1997
- `disabled` (Bool; optional): If True, no dates can be selected.
- `clearable` (Bool; optional): Whether or not the dropdown is "clearable", that is, whether or
not a small "x" appears on the right of the dropdown that removes
the selected value.
- `style` (Dict; optional): CSS styles appended to wrapper div
- `className` (String; optional): Appends a CSS class to the wrapper div component.
- `loading_state` (optional): Object that holds the loading state object coming from dash-renderer. loading_state has the following type: lists containing elements 'is_loading', 'prop_name', 'component_name'.
Those elements have the following types:
  - `is_loading` (Bool; optional): Determines if the component is loading or not
  - `prop_name` (String; optional): Holds which property is loading
  - `component_name` (String; optional): Holds the name of the component that is loading
- `persistence` (Bool | String | Real; optional): Used to allow user interactions in this component to be persisted when
the component - or the page - is refreshed. If `persisted` is truthy and
hasn't changed from its previous value, a `date` that the user has
changed while using the app will keep that change, as long as
the new `date` also matches what was given originally.
Used in conjunction with `persistence_type`.
- `persisted_props` (Array of a value equal to: 'date's; optional): Properties whose user interactions will persist after refreshing the
component or the page. Since only `date` is allowed this prop can
normally be ignored.
- `persistence_type` (a value equal to: 'local', 'session', 'memory'; optional): Where persisted user changes will be stored:
memory: only kept in memory, reset on page refresh.
local: window.localStorage, data is kept after the browser quit.
session: window.sessionStorage, data is cleared once the browser quit.
"""
function dcc_datepickersingle(; kwargs...)
        available_props = Symbol[:id, :date, :min_date_allowed, :max_date_allowed, :initial_visible_month, :day_size, :calendar_orientation, :is_RTL, :placeholder, :reopen_calendar_on_clear, :number_of_months_shown, :with_portal, :with_full_screen_portal, :first_day_of_week, :stay_open_on_select, :show_outside_days, :month_format, :display_format, :disabled, :clearable, :style, :className, :loading_state, :persistence, :persisted_props, :persistence_type]
        wild_props = Symbol[]
        return Component("dcc_datepickersingle", "DatePickerSingle", "dash_core_components", available_props, wild_props; kwargs...)
end

max_stars_repo_name: asc-csa/dash-core-components

max_issues_repo_name: asc-csa/dash-core-components

max_forks_repo_name: asc-csa/dash-core-components


text:
module Logger

export ModelLogger, Diagnostic, Setup, Simulation

using Dates
using Logging

#####
##### Custom LogLevels
#####

_custom_log_level_docs = """
    Severity Order:
    Debug < Diagnostic < Simulation < Setup < Info

    Usage:
    @logmsg Logging.LogLevel "Log Message"

    @logmsg comes from Base/Logging
    LogLevel can be any Base/Logging.LogLevel
    Log Message can be any expression that evaluates to a string (preferably human readable!)
"""

const Diagnostic = Logging.LogLevel(-500)  # Sits between Debug and Info
const Simulation = Logging.LogLevel(-250)
const Setup      = Logging.LogLevel(-125)

#####
##### ModelLogger
#####

_model_logger_docs = """

    ModelLogger(stream::IO, level::LogLevel)

Based on Logging.SimpleLogger it tries to log all messages in the following format

    message --- [dd/mm/yyyy HH:MM:SS] log_level source_file:line_number

The logger will handle any message from Diagnostic up by default.
"""
struct ModelLogger <: Logging.AbstractLogger
    stream::IO
    min_level::Logging.LogLevel
    message_limits::Dict{Any,Int}
end

ModelLogger(stream::IO=stderr, level=Diagnostic) = ModelLogger(stream, level, Dict{Any,Int}())

Logging.shouldlog(logger::ModelLogger, level, _module, group, id) = get(logger.message_limits, id, 1) > 0

Logging.min_enabled_level(logger::ModelLogger) = logger.min_level

Logging.catch_exceptions(logger::ModelLogger) = false

function level_to_string(level::Logging.LogLevel)
    if level == Diagnostic
         "Diagnostic"
    elseif level == Setup
         "Setup"
    elseif level == Logging.Warn
        "Warning"
    else
        string(level)
    end
end

function Logging.handle_message(logger::ModelLogger, level, message, _module, group, id, filepath, line; maxlog = nothing, kwargs...)
    if maxlog !== nothing && maxlog isa Integer
        remaining = get!(logger.message_limits, id, maxlog)
        logger.message_limits[id] = remaining - 1
        remaining > 0 || return
    end
    buf = IOBuffer()
    iob = IOContext(buf, logger.stream)
    level_name = level_to_string(level)
    module_name = something(_module, "nothing")
    file_name = something(filepath, "nothing")
    line_number = something(line, "nothing")
    msg_timestamp = Dates.format(Dates.now(), "[dd/mm/yyyy HH:MM:SS]")
    formatted_message = "$message --- $msg_timestamp $level_name $file_name:$line_number"
    println(iob, formatted_message)
    write(logger.stream, take!(buf))
    return nothing
end

end

ext: jl


text:
using Plexifications
using Base.Test: @test, @test_throws

@test_throws ErrorException begin
    inv(HyperPerplex(0, 0.0))
end

@test begin
    iszerodivisor(HyperPerplex(1,1,3,2))
end

@test begin
    !iszerodivisor(HyperPerplex(1,2,3,5))
end

@test begin
    a = Plexifications.randomBigFloat()
    isreal(HyperPerplex(a))
end

@test begin
    a = 1
    !isreal(HyperPerplex(a, a))
end

@test begin
    z = random(HyperPerplex{Int})
    z == +(z)
end

@test begin
    a = Plexifications.randomBigFloat()
    real(HyperPerplex(a)) == a
end

@test begin
    io = IOBuffer()
    show(io, HyperPerplex(1, 2, 3, 4, 5, 6, 7, 8))
    l = String(take!(io))
    r = "[1: 1, R: 2, A: 3, RA: 4, B: 5, RB: 6, AB: 7, RAB: 8]"
    l == r
end

@test begin
    x = random(HyperPerplex{BigFloat})
    y = random(HyperPerplex{BigFloat})
    x != y
end

@test begin
    a = Plexifications.randomBigInt()
    z = random(HyperPerplex{BigInt})
    l = a + z
    r = z + a
    l == r
end

@test begin
    a = Plexifications.randomBigInt()
    z = random(HyperPerplex{BigInt})
    l = a - z
    r = -(z - a)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = x + y
    r = y + x
    l == r
end

@test begin
    x = random(DualPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = x + y
    r = y + x
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = x * y
    r = y * x
    l == r
end

@test begin
    x = random(DualPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = x * y
    r = y * x
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = x - y
    r = -(y - x)
    l == r
end

@test begin
    x = random(DualPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = x - y
    r = -(y - x)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    z = random(HyperPerplex{BigInt})
    l = (x + y) + z
    r = x + (y + z)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    z = random(HyperPerplex{BigInt})
    l = (x * y) * z
    r = x * (y * z)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    barA(barA(x)) == x
end

@test begin
    x = random(HyperPerplex{BigInt})
    barB(barB(x)) == x
end

@test begin
    x = random(HyperPerplex{BigInt})
    barR(barR(x)) == x
end

@test begin
    x = random(HyperPerplex{BigInt})
    barB(barA(x)) == barA(barB(x))
end

@test begin
    x = random(HyperPerplex{BigInt})
    barR(barA(x)) == barA(barR(x))
end

@test begin
    x = random(HyperPerplex{BigInt})
    barB(barR(x)) == barR(barB(x))
end

@test begin
    x = random(HyperPerplex{Rational{BigInt}})
    inv(inv(x)) == x
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = barA(x * y)
    r = barA(x) * barA(y)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = barA(x + y)
    r = barA(x) + barA(y)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = barA(x - y)
    r = barA(x) - barA(y)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = barB(x * y)
    r = barB(x) * barB(y)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = barB(x + y)
    r = barB(x) + barB(y)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = barB(x - y)
    r = barB(x) - barB(y)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = barR(x * y)
    r = barR(x) * barR(y)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = barR(x + y)
    r = barR(x) + barR(y)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = barR(x - y)
    r = barR(x) - barR(y)
    l == r
end

@test begin
    x = random(HyperPerplex{Rational{BigInt}})
    y = random(HyperPerplex{Rational{BigInt}})
    l = inv(x * y)
    r = inv(y) * inv(x)
    l == r
end

@test begin
    x = random(HyperPerplex{Rational{BigInt}})
    y = random(HyperPerplex{Rational{BigInt}})
    l = inv(x / y)
    r = y / x
    l == r
end

@test begin
    x = random(HyperPerplex{Rational{BigInt}})
    y = random(HyperPerplex{Rational{BigInt}})
    l = inv(x \ y)
    r = y \ x
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    z = random(HyperPerplex{BigInt})
    l = x * (y + z)
    r = (x * y) + (x * z)
    l == r
end

@test begin
    a = Plexifications.randomBigInt()
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = a * (x + y)
    r = (a * x) + (a * y)
    l == r
end

@test begin
    a = Plexifications.randomBigInt()
    x = random(HyperPerplex{BigInt})
    l = a * x
    r = x * a
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    z = random(HyperPerplex{BigInt})
    l = (x + y) * z
    r = (x * z) + (y * z)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    z = random(HyperPerplex{BigInt})
    l = x * (y - z)
    r = (x * y) - (x * z)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    z = random(HyperPerplex{BigInt})
    l = (x - y) * z
    r = (x * z) - (y * z)
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    n = norm(x)
    n > big(0) || n == big(0)
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = norm(x * y)
    r = norm(x) * norm(y)
    l == r
end

@test_throws ErrorException begin
    inv(HyperPerplex(0, 0.0))
end

@test_throws ErrorException begin
    random(HyperPerplex{Int}) / 0
end

@test_throws ErrorException begin
    0 \ random(HyperPerplex{Int})
end

@test begin
    a = Plexifications.randomBigRational()
    z = random(HyperPerplex{Rational{BigInt}})
    l = z / a
    r = a \ z
    l == r
end

@test begin
    a = Plexifications.randomBigRational()
    z = random(HyperPerplex{Rational{BigInt}})
    l = a / z
    r = z \ a
    l == r
end

@test begin
    z = random(HyperPerplex{BigInt})
    z == z + zero(HyperPerplex{BigInt})
end

@test begin
    z = random(HyperPerplex{BigInt})
    z == z * one(HyperPerplex{BigInt})
end

@test begin
    z = random(HyperPerplex{BigInt})
    z == z + zero(z)
end

@test begin
    z = random(HyperPerplex{BigInt})
    z == z * one(z)
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = commutator(x, y)
    r = zero(HyperPerplex{BigInt})
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = alternatorL(x, y)
    r = zero(HyperPerplex{BigInt})
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = alternatorR(x, y)
    r = zero(HyperPerplex{BigInt})
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    l = flexator(x, y)
    r = zero(HyperPerplex{BigInt})
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    z = random(HyperPerplex{BigInt})
    l = associator(x, y, z)
    r = zero(HyperPerplex{BigInt})
    l == r
end

@test begin
    x = random(HyperPerplex{BigInt})
    y = random(HyperPerplex{BigInt})
    z = random(HyperPerplex{BigInt})
    l = jacobiator(x, y, z)
    r = 3 * x * y * z
    l == r
end

@test begin
    l = HyperPerplex(Prplex(1,2))
    r = HyperPerplex(1,2)
    l == r
end

@test begin
    l = HyperPerplex(DualPerplex(1,2))
    r = HyperPerplex(1,2,0)
    l == r
end

@test begin
    l = HyperPerplex(1, 2, 3.0)
    r = HyperPerplex(1.0, 2.0, 3.0)
    l == r
end

@test begin
    l = HyperPerplex(1, 2, 3, 4.0)
    r = HyperPerplex(1.0, 2.0, 3.0, 4.0)
    l == r
end

@test begin
    l = HyperPerplex(1, 2, 3, 4, 5.0)
    r = HyperPerplex(1.0, 2.0, 3.0, 4.0, 5.0)
    l == r
end

@test begin
    l = HyperPerplex(1, 2, 3, 4, 5, 6.0)
    r = HyperPerplex(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)
    l == r
end

@test begin
    l = HyperPerplex(1, 2, 3, 4, 5, 6, 7.0)
    r = HyperPerplex(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)
    l == r
end

@test begin
    l = HyperPerplex(1, 2, 3, 4, 5, 6, 7, 8.0)
    r = HyperPerplex(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
    l == r
end


text:
### A Pluto.jl notebook ###
# v0.18.4

using Markdown
using InteractiveUtils

# ╔═╡ 8fc01a3c-b6d9-45ef-b06d-b8e768d0e01b
md"# 3월15일"

# ╔═╡ f225423e-925f-4480-80f3-ddc9a68ab854
html"""

"""

# ╔═╡ a39e054e-0447-4f3b-80c7-cab889e27964
md"## Usings"

# ╔═╡ 03a212a7-c80e-42d7-8ec2-8de166ffbd13
import PlutoUI

# ╔═╡ 2c3e71b0-23dc-445a-b270-69e16f69cb97
PlutoUI.TableOfContents(aside=true)

# ╔═╡ 5a5c3101-a0ee-4b7d-bb04-1ce2fb3d9e7a
md"##### 지난시간 숙제풀이"

# ╔═╡ 18221dae-f8bc-48c1-899b-be73d6e4910a
[2^i for i in 0:10]

# ╔═╡ 12839273-8a7e-48a1-9be8-26c6e8f2e3de
md"## matrix"

# ╔═╡ c5e2fb02-21d5-44e9-985e-75078d4c5bf5
md"### 선언"

# ╔═╡ d1d3c552-9b9e-4d45-8778-ce30d4b9dfda
md"`-` 선언하는 방법"

# ╔═╡ c7e638e0-11f6-4805-aa0e-913071056172
[1 2 3; 4 5 6] # ;는 거의 엔터처럼 생각하면 된다.

# ╔═╡ dc2f43b3-fb66-4f96-86d6-48ade6e3b605
[1 2 3
4 5 6] # 그냥 실제 엔터 쳐도 선언 가능

# ╔═╡ ce9b5739-6213-434e-8444-ceb4cabbef28
[
	1 2 3
	4 5 6
] # 보기좋게?

# ╔═╡ ff454362-f653-476f-870d-7b6b3e9ee7e1
md"`-` (1,4) matrix = lenght 4 row-vector 선언"

# ╔═╡ a84c236d-1156-4997-8b83-7813a26cfd72
[1 2 3 4]

# ╔═╡ 9ba2ce1b-2173-479b-989b-42e8f22d5700
[1 ;; 2 ;; 3 ;; 4] # 이것도 가능

# ╔═╡ 8cf64d00-2d6b-4dbc-a319-7ef69079faf0
md"`-` (4,1) marix = length 4 col-vector 선언"

# ╔═╡ 84ee925b-4489-484f-b6bd-71e1f1acfd1e
[1;2;3;4]

# ╔═╡ 8220ad15-ffd8-400e-a816-e6062e8ff883
[1,2,3,4] # 이게 사실은 length 4인 col-vector 로 여길수 있음..

# ╔═╡ 94f18da5-5a21-49e4-8691-f63142373281
[
	1
	2
	3
	4
] # 편해요..

# ╔═╡ 1b226aa6-c4b5-4a9d-a649-85907ae97903
md"`-` (4,2) matrix 선언과 잘못된 선언 "

# ╔═╡ ad6c5952-3e86-415b-a127-42238734a3a9
[1 2; 2 3 ; 3 4 ; 4 5]

# ╔═╡ 3114f121-4b51-4acd-8e30-409cb42fcd3b
[1 2, 2 3 , 3 4 , 4 5] # 잘못된 선언방식

# ╔═╡ 7fa90a53-b739-4e42-a5c1-76ee80cbe3e4
[
	1 2
	2 3
	3 4
	4 5
] # 이게 젤 편해요

# ╔═╡ ecc5e457-f400-4a07-bb34-6325a5830c65
md"### 연산"

# ╔═╡ 223c1e25-5339-4de4-92f6-303e909da489
md"`-` 곱셈"

# ╔═╡ cf6bfe27-2d26-4472-8789-0456693a3a11
[1 0 ; 0 1] * [1,2]

# ╔═╡ 2bc395b2-6186-4b20-9788-f52b939464d5
[1,2] * [1 0 ; 0 1]

# ╔═╡ 25327f5a-ca46-431e-aab2-71bb070720c6
md"- 에러메시지의 교훈: 아.. [1,2]는 진짜 col-vector이구나.."

# ╔═╡ af334ef5-d37b-4b05-8cc6-cbb585c9a888
[1 2] * [1 0 ; 0 1]

# ╔═╡ 156f33fc-2d64-4e8b-b931-5920a83bf97a
md"`-` 트랜스포즈"

# ╔═╡ de53accd-33b4-4ac9-b7ec-a6c95a3af761
md"(연산자사용)"

# ╔═╡ bb2c3099-7a48-45f6-9b3d-dba1ff0ac970
[1 2; 3 4]

# ╔═╡ 35660a52-e360-4538-b7fc-d06b6fcb1723
[1 2; 3 4]'

# ╔═╡ dd37cfac-a210-44a7-9984-11267dc2dedb
[1,2,3,4]'

# ╔═╡ 69835a56-c9c6-4561-b24a-4e9ce1919637
md"(복잡한방법)"

# ╔═╡ fd62d9d1-f82e-4c00-92fd-6e0c33e2a329
adjoint([1 2; 3 4])

# ╔═╡ 52e6d112-987c-41bd-962a-ebd711648ba5
md"""
### hcat, vcat
"""

# ╔═╡ 6823bb9e-e1d0-46cb-8b80-8e0c7f9bc723
md"""
`-` hcat: R에서의 cbind, 좌우로 붙인다

`-` hcat: R에서의 rbind, 위 아래로 붙인다
"""

# ╔═╡ c6fe9b45-aa6e-4f38-9118-bbf4567ce55f
hcat([1,2,3],[11,12,13])
# 3*1 col-vec (hcat) 3*1 col-vec => 3*2 matrix

# ╔═╡ 5d7aade6-c7eb-4979-af83-d85cc7dbc5ec
hcat([1,2,3],[11,12,13],[111,112,113])
# 3*1 col-vec (hcat) 3*1 col-vec (hcat) => 3*3 matrix

# ╔═╡ 4bc16860-dd17-4831-8365-83cb8073f9c4
hcat([1 11 ; 2 12 ; 3 13 ], [111, 222, 333])
# 3*2 matrix (hcat) 3*1 col-vec (hcat) => 3*3 matrix

# ╔═╡ 3b41c9cd-63f8-4491-abed-c933834718d6
hcat([1 11 ; 2 12 ; 3 13 ], [111 222 333])
# 3*2 matrix (hcat) 1*3 row-vec (hcat) => 불가능

# ╔═╡ ec4455f7-1926-47e7-b040-ab6f6a4f6f37
vcat([1 2 3 4], [11 22 33 44])
# 1*4 row-vec (vcat) 1*4 row-vec ==> 2*4 matrix

# ╔═╡ f58c8d79-486d-462c-b1c8-c42e45174a9d
vcat(hcat(vcat([1 2 3 4], [11 22 33 44]),[-1,-2]),[-1 -2 -3 -4 -5])
# 혼합하여사용가능

# ╔═╡ ed11ba08-eca6-4fe4-b954-c46d98e581e9
md"""
##### hcat, vcat의 더 쉬운 사용방법
"""

# ╔═╡ bc5ee879-28c0-4142-b24e-57e9001f1b05
[[1,2,3] [4,5,6]] # hcat(A,B) = [A B]

# ╔═╡ 02534d28-24c4-4124-80a3-87e0b6d05ff8
[[1 2 3; 4 5 6] ; [7 8 9]] # vcat(A,B) = [A; B]

# ╔═╡ 1db942d9-b61d-45e0-9db0-625806de8663
[
	[1 2 3; 4 5 6]
	[7 8 9]
]

# ╔═╡ 51d5d6ec-4788-443e-b4a1-0da210cbaf25
[
	[
		1 2 3
		4 5 6
	]

	[
		7 8 9
	]
]

# ╔═╡ bb94a5ad-ee1b-462b-b2d9-731a45603328
md"편하고 좋아요.."

# ╔═╡ a77dff93-bb99-4c93-b00f-8de0135edcc0
a1=[1 2
    3 4]

# ╔═╡ 4e7f10d6-d4f3-4dba-bd82-4e1e027cd132
a2=[5
    6]

# ╔═╡ 2daa7139-87b5-4e07-b5c1-ee7a9b61348f
a3=[7 8]

# ╔═╡ a2b53145-323a-40f9-b138-45f3b0a5854e
[
	a1 a2
	a3 9
]

# ╔═╡ f0ca14d2-0b13-4fad-93fc-d5806957cd40
[
	a1 a3
	a2 9
] # 디멘젼이 맞지 않으므로 에러가 발생

# ╔═╡ d399a7b2-4ac5-4f2e-8039-6ffb0b09d6e6
md"### reshape"

# ╔═╡ e8dfcb15-a94d-49e6-96c7-033c649edfdb
reshape(1:6, (2,3))

# ╔═╡ b07575ab-67ed-4fcb-9574-a0e2e29bde09
reshape(1:6, (3,2))

# ╔═╡ 4e77e610-ab8a-4b08-99cc-8e5ca15522c0
reshape(1:6, (6,1))

# ╔═╡ e5a82661-28f9-42c1-8763-a633dd89c2db
reshape(1:6, (1,6))

# ╔═╡ 213fdb89-cf30-44d2-a3b2-a6da706decc3
reshape(1:8, (2,2,2))

# ╔═╡ 86a67dfe-da9c-4ed6-980e-131b8892065d
reshape(1:24, (2,2,2,3))

# ╔═╡ 24e90ab1-6bc5-44c7-a659-3a2ea3494177
md"## 벡터와 매트릭스 (자투리)"

# ╔═╡ b8373e03-4558-46f5-8f57-90f3b52d0193
md"### range"

# ╔═╡ aaa05575-1873-45f0-acf6-b18c5b3f5c29
1:3

# ╔═╡ 861b5ade-2ed9-4b28-a8ae-50d0c5e4705a
typeof(1:3)

# ╔═╡ da842d51-53b6-4ec6-875e-f6c8e7b7681b
Array(1:3)

# ╔═╡ 4ba39004-4c1e-4f99-878f-2ed95b4e9e52
typeof(Array(1:3))

# ╔═╡ 484c5ed1-65c3-42b2-9962-9916320c1856
Array(1:3:20)

# ╔═╡ 34fe6d7c-e440-453d-9d68-d11b706a8d4b
md"`-` range도 연산이 가능함"

# ╔═╡ 0afe44aa-d5e9-4f85-9ed2-27c73fd24a9a
(1:3) + (1:3)

# ╔═╡ 7cb2f34d-8362-418a-becd-3f754ce43ec7
Array((1:3) + (1:3))

# ╔═╡ 99b09469-a7f9-47ce-a21b-b82574db5cb7
(1:3) .* 2 .+ 100

# ╔═╡ ae011f7f-7ec2-43eb-a213-9dce06dcca29
Array((1:3) .* 2 .+ 100)

# ╔═╡ 25022f43-7561-4d74-948b-a149bb629fe2
md"### indexing"

# ╔═╡ 28899b48-3b43-44a2-b18d-d7727d44ef7c
md"`-` 1차원으로 인덱싱"

# ╔═╡ 47335258-4e82-4a3f-b85b-2ba48f582269
A= [1 2 3
	4 5 6
	7 8 9]

# ╔═╡ 7805cdde-7bb2-44ea-806c-9fb5ab39075f
A[1:4]

# ╔═╡ 53d142ac-3d20-4d24-b01a-77f9c0f2cc77
A[[1,3,5,7]]

# ╔═╡ 76f991d0-5e8f-431f-82ba-d592ef135ecf
md"`-` 2차원으로 인덱싱"

# ╔═╡ fe76a4cd-c685-460b-96e2-34c91fecc990
A[:,1] # 첫번째 col

# ╔═╡ 453a23b7-e99d-40b1-a94e-37eb4e870e09
A[:,[1]] # 첫번째 col /// 좀더 명시적으로!

# ╔═╡ 082932b1-899d-4f9d-a14f-87a75c7c05ba
A[1,:] # 첫번째 row

# ╔═╡ ff2f6191-e7bd-4dc5-8947-e4dc3166313b
A[[1],:] # 첫번째 row /// 좀더 명시적으로!

# ╔═╡ 752e9d30-43f6-4890-9a9d-b982f61a533d
A[[1,3],:] # 첫번째 row, 세번째 row

# ╔═╡ 7a30be54-59a8-48dc-a835-b833b1c58049
A[[1,3],2] # (첫번째 row, 세번째 row) ==> 두번째 칼럼

# ╔═╡ 5a5cdbbd-8dbc-4a32-b0f4-f6cce879412d
A[[1,3],[2]] # (첫번째 row, 세번째 row) ==> 두번째 칼럼 /// 좀더 명시적으로!

# ╔═╡ 03895c3f-2353-42a1-8f2a-e28e29574c34
md"`-` 고차원"

# ╔═╡ 45c44acf-319a-4601-8be3-ec84dea11ef8
B=reshape(1:36,(3,3,2,2))

# ╔═╡ a0f37987-7d7c-4867-8dc5-97343ae3cd63
B[1:2, 2:3, 1, :]

# ╔═╡ 014e1f0c-5c23-4104-851d-d6112f2cc9f2
B[1:2, [1,3], :, 1]

# ╔═╡ 96108638-d8a0-41ea-9332-8559c6917db5
md"`-` 로지칼인덱싱"

# ╔═╡ 5daf498c-4ab3-47ea-b15a-c88fc8d1e014
a=[1,2,3,4]

# ╔═╡ 806e5f53-e17a-4e01-a9a7-1ff79839677c
a[[true,false,true,false]]

# ╔═╡ f93db673-a907-4fe9-a54b-0c505a1c99d9
a[a.>2]

# ╔═╡ e27a7070-9a40-46b7-9054-3f4424ab841a
md"## 함수선언"

# ╔═╡ 384c4e1f-e557-4437-8122-3ea468d60961
md"### 여러가지 방식"

# ╔═╡ a67f2187-6028-4431-a2e9-71327bc5efa1
md"""
##### 스타일 1
"""

# ╔═╡ 441e0f33-fe0a-4eca-8d68-232b8a6f29d2
function f1(x,y)
	return √(x^2+y^2) # return 명시
end

# ╔═╡ 0460f841-982a-46f5-99af-955c14991075
f1(1,1)

# ╔═╡ eb67bdd5-37ff-41a1-b5c4-736fd72a61e5
md"##### 스타일2"

# ╔═╡ 2fd8d9f4-e9b4-4d88-86e7-03ecaddfd692
function f2(x,y)
	a= x^2 + y^2
	√a # return 생략
end

# ╔═╡ fce1fbc1-5caa-4a57-8a31-1b4ba007f104
f2(1,1)

# ╔═╡ 44bba248-9a02-4ea6-b9cd-41abe978e5a9
md"##### 스타일3"

# ╔═╡ 33934ed6-14d4-45d1-bc49-ff24db2ced80
f3(x,y) = √(x^2+y^2)

# ╔═╡ 23df5e92-30bd-4bad-8242-7ccb56b3c064
f3(1,1)

# ╔═╡ 4665d68f-fba8-47b3-a978-034d8e9a6c2d
md"##### 스타일4"

# ╔═╡ 57bbe8e9-280f-4d75-8f08-6559599b8188
f4 = (x,y) -> √(x^2+y^2)

# ╔═╡ e1dfd750-39b3-4e82-960f-53fe45d25fab
f4(1,1)

# ╔═╡ 5bbee205-fe9b-4477-9bc8-14d2f6540cf5
md"##### 스타일5"

# ╔═╡ 762d650b-7a7f-47d1-a571-231272e85f5e
((x,y) -> √(x^2+y^2))(1,1)

# ╔═╡ d432ab84-069e-462d-9c7f-10ad8020a827
md"### 합성함수"

# ╔═╡ 6fbe924e-feda-4a64-b752-4d752fa754e0
f= (x -> 3x) ∘ (x -> x+1) # f(x)= 3(x+1) 란 의미

# ╔═╡ 2c3ebb43-4835-4647-8907-0bfe6ba940ef
f(-5)

# ╔═╡ 2b081a93-3e67-4027-a9c2-99691ce15130
md"## 숙제"

# ╔═╡ a1732e88-bdc7-477a-89e1-d099556cdf49
md"함수 $f(x)=(x-1)^2$를 함성함수를 이용하여 선언하고 $(x,f(x))$의 그래프를 $x \in (-1,3)$의 범위에서 그린뒤에 제출 (단, x는 -1에서 시작하여 3으로 0.05간격의 벡터를 이용하여 생성한뒤에 그릴것)"

# ╔═╡ f434a8cc-e9e0-471f-b821-860b4aea670e
md"hints"

# ╔═╡ 57aa3e4d-63b9-4214-a7fe-351e5dde237c
Array(-1:0.05:3)

# ╔═╡ b63d3749-fae4-4fc6-b0a5-08fe150b174d
g(x) = x+1

# ╔═╡ f98034cc-f76a-4bc8-8655-200081eb4fca
[g(x) for x in 1:5]

# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"

[compat]
PlutoUI = "~0.7.37"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised

julia_version = "1.7.2"
manifest_format = "2.0"

[[deps.AbstractPlutoDingetjes]]
deps = ["Pkg"]
git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481"
uuid = "6e696c72-6542-2067-7265-42206c756150"
version = "1.1.4"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"

[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
git-tree-sha1 = "024fe24d83e4a5bf5fc80501a314ce0d1aa35597"
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.11.0"

[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"

[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[deps.Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"

[[deps.FixedPointNumbers]]
deps = ["Statistics"]
git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
version = "0.8.4"

[[deps.Hyperscript]]
deps = ["Test"]
git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9"
uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91"
version = "0.0.4"

[[deps.HypertextLiteral]]
git-tree-sha1 = "2b078b5a615c6c0396c77810d92ee8c6f470d238"
uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
version = "0.9.3"

[[deps.IOCapture]]
deps = ["Logging", "Random"]
git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a"
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
version = "0.2.2"

[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[deps.JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.3"

[[deps.LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"

[[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"

[[deps.LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[deps.LinearAlgebra]]
deps = ["Libdl", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[deps.Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"

[[deps.Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"

[[deps.NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"

[[deps.Parsers]]
deps = ["Dates"]
git-tree-sha1 = "85b5da0fa43588c75bb1ff986493443f821c70b7"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.2.3"

[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[deps.PlutoUI]]
deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "Markdown", "Random", "Reexport", "UUIDs"]
git-tree-sha1 = "bf0a1121af131d9974241ba53f601211e9303a9e"
uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
version = "0.7.37"

[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[deps.Random]]
deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[deps.Reexport]]
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.2.2"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[deps.SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[deps.Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[deps.TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[[deps.Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"

[[deps.Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[deps.Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"

[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl", "OpenBLAS_jll"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"

[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"

[[deps.p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
"""

# ╔═╡ Cell order:
# ╟─8fc01a3c-b6d9-45ef-b06d-b8e768d0e01b
# ╟─f225423e-925f-4480-80f3-ddc9a68ab854
# ╟─a39e054e-0447-4f3b-80c7-cab889e27964
# ╠═03a212a7-c80e-42d7-8ec2-8de166ffbd13
# ╠═2c3e71b0-23dc-445a-b270-69e16f69cb97
# ╟─5a5c3101-a0ee-4b7d-bb04-1ce2fb3d9e7a
# ╠═18221dae-f8bc-48c1-899b-be73d6e4910a
# ╟─12839273-8a7e-48a1-9be8-26c6e8f2e3de
# ╟─c5e2fb02-21d5-44e9-985e-75078d4c5bf5
# ╟─d1d3c552-9b9e-4d45-8778-ce30d4b9dfda
# ╠═c7e638e0-11f6-4805-aa0e-913071056172
# ╠═dc2f43b3-fb66-4f96-86d6-48ade6e3b605
# ╠═ce9b5739-6213-434e-8444-ceb4cabbef28
# ╟─ff454362-f653-476f-870d-7b6b3e9ee7e1
# ╠═a84c236d-1156-4997-8b83-7813a26cfd72
# ╠═9ba2ce1b-2173-479b-989b-42e8f22d5700
# ╟─8cf64d00-2d6b-4dbc-a319-7ef69079faf0
# ╠═84ee925b-4489-484f-b6bd-71e1f1acfd1e
# ╠═8220ad15-ffd8-400e-a816-e6062e8ff883
# ╠═94f18da5-5a21-49e4-8691-f63142373281
# ╟─1b226aa6-c4b5-4a9d-a649-85907ae97903
# ╠═ad6c5952-3e86-415b-a127-42238734a3a9
# ╠═3114f121-4b51-4acd-8e30-409cb42fcd3b
# ╠═7fa90a53-b739-4e42-a5c1-76ee80cbe3e4
# ╟─ecc5e457-f400-4a07-bb34-6325a5830c65
# ╟─223c1e25-5339-4de4-92f6-303e909da489
# ╠═cf6bfe27-2d26-4472-8789-0456693a3a11
# ╠═2bc395b2-6186-4b20-9788-f52b939464d5
# ╟─25327f5a-ca46-431e-aab2-71bb070720c6
# ╟─af334ef5-d37b-4b05-8cc6-cbb585c9a888
# ╟─156f33fc-2d64-4e8b-b931-5920a83bf97a
# ╟─de53accd-33b4-4ac9-b7ec-a6c95a3af761
# ╠═bb2c3099-7a48-45f6-9b3d-dba1ff0ac970
# ╠═35660a52-e360-4538-b7fc-d06b6fcb1723
# ╠═dd37cfac-a210-44a7-9984-11267dc2dedb
# ╟─69835a56-c9c6-4561-b24a-4e9ce1919637
# ╠═fd62d9d1-f82e-4c00-92fd-6e0c33e2a329
# ╟─52e6d112-987c-41bd-962a-ebd711648ba5
# ╟─6823bb9e-e1d0-46cb-8b80-8e0c7f9bc723
# ╠═c6fe9b45-aa6e-4f38-9118-bbf4567ce55f
# ╠═5d7aade6-c7eb-4979-af83-d85cc7dbc5ec
# ╠═4bc16860-dd17-4831-8365-83cb8073f9c4
# ╠═3b41c9cd-63f8-4491-abed-c933834718d6
# ╠═ec4455f7-1926-47e7-b040-ab6f6a4f6f37
# ╠═f58c8d79-486d-462c-b1c8-c42e45174a9d
# ╟─ed11ba08-eca6-4fe4-b954-c46d98e581e9
# ╠═bc5ee879-28c0-4142-b24e-57e9001f1b05
# ╠═02534d28-24c4-4124-80a3-87e0b6d05ff8
# ╠═1db942d9-b61d-45e0-9db0-625806de8663
# ╠═51d5d6ec-4788-443e-b4a1-0da210cbaf25
# ╟─bb94a5ad-ee1b-462b-b2d9-731a45603328
# ╠═a77dff93-bb99-4c93-b00f-8de0135edcc0
# ╠═4e7f10d6-d4f3-4dba-bd82-4e1e027cd132
# ╠═2daa7139-87b5-4e07-b5c1-ee7a9b61348f
# ╠═a2b53145-323a-40f9-b138-45f3b0a5854e
# ╠═f0ca14d2-0b13-4fad-93fc-d5806957cd40
# ╟─d399a7b2-4ac5-4f2e-8039-6ffb0b09d6e6
# ╠═e8dfcb15-a94d-49e6-96c7-033c649edfdb
# ╠═b07575ab-67ed-4fcb-9574-a0e2e29bde09
# ╠═4e77e610-ab8a-4b08-99cc-8e5ca15522c0
# ╠═e5a82661-28f9-42c1-8763-a633dd89c2db
# ╠═213fdb89-cf30-44d2-a3b2-a6da706decc3
# ╠═86a67dfe-da9c-4ed6-980e-131b8892065d
# ╟─24e90ab1-6bc5-44c7-a659-3a2ea3494177
# ╟─b8373e03-4558-46f5-8f57-90f3b52d0193
# ╠═aaa05575-1873-45f0-acf6-b18c5b3f5c29
# ╠═861b5ade-2ed9-4b28-a8ae-50d0c5e4705a
# ╠═da842d51-53b6-4ec6-875e-f6c8e7b7681b
# ╠═4ba39004-4c1e-4f99-878f-2ed95b4e9e52
# ╠═484c5ed1-65c3-42b2-9962-9916320c1856
# ╟─34fe6d7c-e440-453d-9d68-d11b706a8d4b
# ╠═0afe44aa-d5e9-4f85-9ed2-27c73fd24a9a
# ╠═7cb2f34d-8362-418a-becd-3f754ce43ec7
# ╠═99b09469-a7f9-47ce-a21b-b82574db5cb7
# ╠═ae011f7f-7ec2-43eb-a213-9dce06dcca29
# ╟─25022f43-7561-4d74-948b-a149bb629fe2
# ╟─28899b48-3b43-44a2-b18d-d7727d44ef7c
# ╠═47335258-4e82-4a3f-b85b-2ba48f582269
# ╠═7805cdde-7bb2-44ea-806c-9fb5ab39075f
# ╠═53d142ac-3d20-4d24-b01a-77f9c0f2cc77
# ╟─76f991d0-5e8f-431f-82ba-d592ef135ecf
# ╠═fe76a4cd-c685-460b-96e2-34c91fecc990
# ╠═453a23b7-e99d-40b1-a94e-37eb4e870e09
# ╠═082932b1-899d-4f9d-a14f-87a75c7c05ba
# ╠═ff2f6191-e7bd-4dc5-8947-e4dc3166313b
# ╠═752e9d30-43f6-4890-9a9d-b982f61a533d
# ╠═7a30be54-59a8-48dc-a835-b833b1c58049
# ╠═5a5cdbbd-8dbc-4a32-b0f4-f6cce879412d
# ╟─03895c3f-2353-42a1-8f2a-e28e29574c34
# ╠═45c44acf-319a-4601-8be3-ec84dea11ef8
# ╠═a0f37987-7d7c-4867-8dc5-97343ae3cd63
# ╠═014e1f0c-5c23-4104-851d-d6112f2cc9f2
# ╟─96108638-d8a0-41ea-9332-8559c6917db5
# ╠═5daf498c-4ab3-47ea-b15a-c88fc8d1e014
# ╠═806e5f53-e17a-4e01-a9a7-1ff79839677c
# ╠═f93db673-a907-4fe9-a54b-0c505a1c99d9
# ╟─e27a7070-9a40-46b7-9054-3f4424ab841a
# ╟─384c4e1f-e557-4437-8122-3ea468d60961
# ╟─a67f2187-6028-4431-a2e9-71327bc5efa1
# ╠═441e0f33-fe0a-4eca-8d68-232b8a6f29d2
# ╠═0460f841-982a-46f5-99af-955c14991075
# ╟─eb67bdd5-37ff-41a1-b5c4-736fd72a61e5
# ╠═2fd8d9f4-e9b4-4d88-86e7-03ecaddfd692
# ╠═fce1fbc1-5caa-4a57-8a31-1b4ba007f104
# ╟─44bba248-9a02-4ea6-b9cd-41abe978e5a9
# ╠═33934ed6-14d4-45d1-bc49-ff24db2ced80
# ╠═23df5e92-30bd-4bad-8242-7ccb56b3c064
# ╟─4665d68f-fba8-47b3-a978-034d8e9a6c2d
# ╠═57bbe8e9-280f-4d75-8f08-6559599b8188
# ╠═e1dfd750-39b3-4e82-960f-53fe45d25fab
# ╟─5bbee205-fe9b-4477-9bc8-14d2f6540cf5
# ╠═762d650b-7a7f-47d1-a571-231272e85f5e
# ╟─d432ab84-069e-462d-9c7f-10ad8020a827
# ╠═6fbe924e-feda-4a64-b752-4d752fa754e0
# ╠═2c3ebb43-4835-4647-8907-0bfe6ba940ef
# ╟─2b081a93-3e67-4027-a9c2-99691ce15130
# ╟─a1732e88-bdc7-477a-89e1-d099556cdf49
# ╟─f434a8cc-e9e0-471f-b821-860b4aea670e
# ╠═57aa3e4d-63b9-4214-a7fe-351e5dde237c
# ╠═b63d3749-fae4-4fc6-b0a5-08fe150b174d
# ╠═f98034cc-f76a-4bc8-8655-200081eb4fca
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002

max_stars_repo_name: seoyeonc/julia

max_issues_repo_name: seoyeonc/julia

max_forks_repo_name: seoyeonc/julia


text:
using SparseArrays, BlockArrays, Base64, FillArrays, LinearAlgebra, Test
import BlockArrays: _BlockArray

function test_error_message(f, needle, expected = Exception)
    err = nothing
    try
        f()
    catch err
    end
    @test err isa expected
    @test occursin(needle, sprint(showerror ,err))
    return err
end

@testset "Block/PseudoArray" begin
    @testset "block constructors" begin
        @testset "BlockArray Constructors" begin
            ret = BlockArray{Float64}(undef, 1:3)
            fill!(ret, 0)
            @test Array(ret)  == zeros(6)

            ret = BlockVector{Float64}(undef, 1:3)
            fill!(ret, 0)
            @test Array(ret)  == zeros(6)

            ret = BlockArray{Float64,1,Vector{Vector{Float64}}}(undef, 1:3)
            fill!(ret, 0)
            @test Array(ret)  == zeros(6)

            ret = BlockArray{Float64}(undef, (blockedrange(1:3),))
            fill!(ret, 0)
            @test Array(ret)  == zeros(6)

            ret = BlockVector{Float64}(undef, (blockedrange(1:3),))
            fill!(ret, 0)
            @test Array(ret)  == zeros(6)

            ret = BlockArray{Float64,1,Vector{Vector{Float64}}}(undef, (blockedrange(1:3),))
            fill!(ret, 0)
            @test Array(ret)  == zeros(6)

            ret = BlockArrays._BlockArray([[0.0],[0.0,0.0],[0.0,0.0,0.0]], 1:3)
            @test Array(ret)  == zeros(6)

            ret = BlockArrays._BlockArray([[0.0],[0.0,0.0],[0.0,0.0,0.0]], (blockedrange(1:3),))
            @test Array(ret)  == zeros(6)

            ret = BlockArray{Float32}(undef_blocks, 1:3)
            @test eltype(ret.blocks) == Vector{Float32}
            @test_throws UndefRefError ret.blocks[1]

            ret = BlockVector{Float32}(undef_blocks, 1:3)
            @test eltype(ret.blocks) == Vector{Float32}
            @test_throws UndefRefError ret.blocks[1]

            ret = BlockArray{Float32,1,Vector{Vector{Float32}}}(undef_blocks, 1:3)
            @test eltype(ret.blocks) == Vector{Float32}
            @test_throws UndefRefError ret.blocks[1]

            ret = BlockArray{Float32}(undef_blocks, 1:3, 1:3)
            @test eltype(ret.blocks) == Matrix{Float32}
            @test_throws UndefRefError ret.blocks[1]

            ret = BlockArray(undef_blocks, Vector{Float32}, 1:3)
            @test eltype(ret) == Float32
            @test eltype(ret.blocks) == Vector{Float32}
            @test_throws UndefRefError ret.blocks[1]

            ret = BlockArray{Float64}(undef, 1:3, 1:3)
            fill!(ret, 0)
            @test Matrix(ret) == zeros(6,6)

            A = [1,2,3,4,5,6]
            @test A == BlockArray(A, 1:3) == BlockArray{Int}(A, 1:3) ==
                BlockArray(A, (blockedrange(1:3),)) == BlockArray{Int}(A, (blockedrange(1:3),)) ==
                BlockArray{Float64}(A, 1:3)
        end

        @testset "PseudoBlockArray constructors" begin
            ret = PseudoBlockArray{Float64}(undef, 1:3)
            fill!(ret, 0)
            @test Array(ret)  == zeros(6)

            ret = PseudoBlockVector{Float64}(undef, 1:3)
            fill!(ret, 0)
            @test Array(ret)  == zeros(6)

            ret = PseudoBlockArray{Float64}(undef, 1:3, 1:3)
            fill!(ret, 0)
            @test Matrix(ret) == zeros(6,6)

            A = [1,2,3,4,5,6]
            @test_throws BoundsError PseudoBlockArray(A,10:20)
            @test A == PseudoBlockArray(A, 1:3) == PseudoBlockArray{Int}(A, 1:3) ==
                PseudoBlockArray(A, (blockedrange(1:3),)) == PseudoBlockArray{Int}(A, (blockedrange(1:3),)) ==
                PseudoBlockArray{Float64}(A, 1:3)
        end

        @testset "similar" begin
            ret = BlockArray{Float64}(undef, 1:3)
            @test similar(ret, Float64, (3,)) isa Vector
            @test similar(typeof(ret), axes(ret)) isa BlockArray
            @test similar(typeof(ret), (Base.OneTo(6),)) isa Array
            @test similar(Array{Float64}, axes(ret)) isa PseudoBlockArray
            @test similar(Vector{Float64}, axes(ret)) isa PseudoBlockArray
            @test similar(randn(5,5), Float64, axes(ret)) isa PseudoBlockArray
            @test similar(ret, Float64, (Base.IdentityUnitRange(1:3),)) isa BlockArray

            ret = PseudoBlockArray{Float64}(undef, 1:3)
            @test similar(ret, Float64, (blockedrange(1:3),)) isa PseudoBlockArray

            ret = BlockArray{Float64}(undef, 1:3, 1:3)
            @test similar(typeof(ret), axes(ret)) isa BlockArray
            @test similar(typeof(ret), (Base.OneTo(6),axes(ret,2))) isa BlockArray
            @test similar(Array{Float64}, axes(ret)) isa PseudoBlockArray
            @test similar(Vector{Float64}, axes(ret)) isa PseudoBlockArray
            @test similar(Array{Float64}, (Base.OneTo(5), axes(ret,2))) isa PseudoBlockArray
            @test similar(randn(5,5), Float64, axes(ret)) isa PseudoBlockArray
            @test similar(randn(5,5), Float64, (Base.OneTo(5), axes(ret,2))) isa PseudoBlockArray

            @test similar(randn(6,5), Float64, (blockedrange(1:3),3)) isa PseudoBlockMatrix
            @test similar(randn(6,5), Float64, (3,blockedrange(1:3))) isa PseudoBlockMatrix
        end

        @test_throws DimensionMismatch BlockArray([1,2,3],[1,1])

        @testset "mortar" begin
            @testset for sizes in [(1:3,), (1:3, 1:3), (1:3, 1:3, 1:3)]
                dims = sum.(sizes)
                A = BlockArray(copy(reshape(1:prod(dims), dims)), sizes...)
                @test mortar(A.blocks) == A
            end

            ret = mortar([spzeros(2), spzeros(3)])
            @test eltype(ret.blocks) <: SparseVector
            @test axes(ret) == (blockedrange([2, 3]),)

            ret = mortar(
                (spzeros(1, 3), spzeros(1, 4)),
                (spzeros(2, 3), spzeros(2, 4)),
                (spzeros(5, 3), spzeros(5, 4)),
            )

            @test Array(ret) == zeros(8, 7)
            @test eltype(ret.blocks) <: SparseMatrixCSC
            @test axes(ret) == blockedrange.(([1, 2, 5], [3, 4]))

            test_error_message("must have ndims consistent with ndims = 1") do
                mortar([ones(2,2)])
            end
            test_error_message("must have ndims consistent with ndims = 2") do
                mortar(reshape([ones(2), ones(2, 2)], (1, 2)))
            end
            test_error_message("size(blocks[2, 2]) (= (111, 222)) is incompatible with expected size: (2, 4)") do
                mortar(
                    (zeros(1, 3), zeros(1, 4)),
                    (zeros(2, 3), zeros(111, 222)),
                )
            end
        end

        @testset "BlockVector" begin
            a_data = [1,2,3]
            a = BlockVector(a_data,[1,2])
            a[1] = 2
            @test a == [2,2,3]
            @test a_data == [1,2,3]
            a = BlockVector(a_data,(blockedrange([1,2]),))
            a[1] = 2
            @test a == [2,2,3]
            @test a_data == [1,2,3]
            a = PseudoBlockVector(a_data,[1,2])
            a[1] = 2
            @test a == [2,2,3]
            @test a_data == [2,2,3]
            a = PseudoBlockVector(a_data,(blockedrange([1,2]),))
            a[1] = 3
            @test a == [3,2,3]
            @test a_data == [3,2,3]
        end

        @testset "BlockMatrix" begin
            a_data = [1 2; 3 4]
            a = BlockMatrix(a_data,[1,1],[2])
            a[1] = 2
            @test a == [2 2; 3 4]
            @test a_data == [1 2; 3 4]
            a = BlockMatrix(a_data,blockedrange.(([1,1],[2])))
            a[1] = 2
            @test a == [2 2; 3 4]
            @test a_data == [1 2; 3 4]
            a = PseudoBlockMatrix(a_data,[1,1],[2])
            a[1] = 2
            @test a == [2 2; 3 4]
            @test a_data == [2 2; 3 4]
            a = PseudoBlockMatrix(a_data, blockedrange.(([1,1],[2])))
            a[1] = 3
            @test a == [3 2; 3 4]
            @test a_data == [3 2; 3 4]
        end

        @testset "UniformScaling" begin
            B = BlockArray(I, fill(2,4), fill(2,5))
            @test B isa BlockMatrix{Bool}
            @test B == BlockMatrix(I, fill(2,4), fill(2,5)) ==
                        BlockArray(I, blockedrange.((fill(2,4), fill(2,5)))) ==
                        BlockMatrix(I, blockedrange.((fill(2,4), fill(2,5)))) ==
                        Matrix(I, 8, 10)

            B = BlockArray{Float64}(I, fill(2,4), fill(2,5))
            @test B isa BlockMatrix{Float64}
            @test B == BlockMatrix{Float64}(I, fill(2,4), fill(2,5)) ==
                        BlockArray{Float64}(I, blockedrange.((fill(2,4), fill(2,5)))) ==
                        BlockMatrix{Float64}(I, blockedrange.((fill(2,4), fill(2,5)))) ==
                        Matrix(I, 8, 10)

            B = PseudoBlockArray(I, fill(2,4), fill(2,5))
            @test B isa PseudoBlockMatrix{Bool}
            @test B == PseudoBlockMatrix(I, fill(2,4), fill(2,5)) ==
                        PseudoBlockArray(I, blockedrange.((fill(2,4), fill(2,5)))) ==
                        PseudoBlockMatrix(I, blockedrange.((fill(2,4), fill(2,5)))) ==
                        Matrix(I, 8, 10)

            B = PseudoBlockArray{Float64}(I, fill(2,4), fill(2,5))
            @test B isa PseudoBlockMatrix{Float64}
            @test B == PseudoBlockMatrix{Float64}(I, fill(2,4), fill(2,5)) ==
                        PseudoBlockArray{Float64}(I, blockedrange.((fill(2,4), fill(2,5)))) ==
                        PseudoBlockMatrix{Float64}(I, blockedrange.((fill(2,4), fill(2,5)))) ==
                        Matrix(I, 8, 10)
        end
    end

    @testset "block indexing" begin
        BA_1 = BlockArray(undef_blocks, Vector{Float64}, [1,2,3])
        @test Base.IndexStyle(typeof(BA_1)) == IndexCartesian()

        a_1 = rand(2)
        BA_1[Block(2)] = a_1
        @test BA_1[BlockIndex(2, 1)] == a_1[1]
        @test BA_1[BlockIndex(2, 2)] == a_1[2]
        @test BA_1[Block(2)] == a_1
        @test BA_1[2] == a_1[1]

        @test_throws DimensionMismatch (BA_1[Block(3)] = rand(4))
        @test_throws BlockBoundsError blockcheckbounds(BA_1, 4)
        @test_throws BlockBoundsError BA_1[Block(4)]

        BA_2 = BlockArray(undef_blocks, Matrix{Float64}, [1,2], [3,4])
        a_2 = rand(1,4)
        BA_2[Block(1,2)] = a_2
        @test BA_2[Block(1,2)] == a_2
        BA_2[Block(1,2)] = a_2

        @test BA_2[1,5] == a_2[2]
        @test_throws DimensionMismatch BA_2[Block(1,2)] = rand(1,5)
    end

    @testset "misc block tests" begin
        for BlockType in (BlockArray, PseudoBlockArray)
            a_1 = rand(6)
            BA_1 = BlockType(a_1, [1,2,3])
            @test Array(BA_1) == a_1
            @test blocksize(BA_1) == (3,)
            @test blocksize(BA_1,1) == 3
            @test eltype(similar(BA_1, Float32)) == Float32
            q = rand(1)
            BA_1[Block(1)] = q
            BA_1[BlockIndex(3, 2)] = a_1[5]
            @test BA_1[Block(1)] == q
            if BlockType == PseudoBlockArray
                q2 = zero(q)
                copyto!(q2, view(BA_1, Block(1)))
                @test q2 == q
                @test_throws BoundsError copyto!(zeros(0), view(BA_1, Block(1)))
                fill!(q2, 0)
                copyto!(q2, view(BA_1, Block(1)))
                @test q2 == q
            end
            fill!(BA_1, 1.0)
            @test BA_1 == ones(size(BA_1))
            ran = rand(size(BA_1)...)
            copyto!(BA_1, ran)
            @test BA_1 == ran

            a_1_sparse = sprand(6, 0.9)
            BA_1_sparse = BlockType(a_1_sparse, [1,2,3])
            @test Array(BA_1_sparse) == a_1_sparse
            BA_1_sparse[4] = 3.0
            @test BA_1_sparse[4] == 3.0

            a_2 = rand(3, 7)
            BA_2 = BlockType(a_2, [1,2], [3,4])
            @test Array(BA_2) == a_2
            @test blocksize(BA_2) == (2,2)
            @test blocksize(BA_2, 1) == 2
            BA_2[BlockIndex((2,1), (2,2))] = a_2[3,2]
            @test eltype(similar(BA_2, Float32)) == Float32
            q = rand(1,4)
            BA_2[Block(1,2)] = q
            @test_throws DimensionMismatch BA_2[Block(1,2)] = rand(1,5)
            @test BA_2[Block(1,2)] == q
            if BlockType == PseudoBlockArray
                q2 = zero(q)
                copyto!(q2, view(BA_2, Block(1, 2)))
                @test q2 == q
                @test copyto!(zeros(1,5), view(BA_2, Block(1, 2))) == [BA_2[Block(1,2)] zeros(1,1)]
            end
            fill!(BA_2, 1.0)
            @test BA_2 == ones(size(BA_2))
            ran = rand(size(BA_2)...)
            copyto!(BA_2, ran)
            @test BA_2 == ran

            a_2_sparse = sprand(3, 7, 0.9)
            BA_2_sparse = BlockType(a_2_sparse, [1,2], [3,4])
            @test Array(BA_2_sparse) == a_2_sparse
            BA_2_sparse[1,2] = 3.0
            @test BA_2_sparse[1,2] == 3.0

            a_3 = rand(3, 7,4)
            BA_3 = BlockType(a_3, [1,2], [3,4], [1,2,1])
            @test Array(BA_3) == a_3
            @test blocksize(BA_3) == (2,2,3)
            @test blocksize(BA_3, 1) == 2
            @test blocksize(BA_3, 3) == 3
            BA_3[BlockIndex((1,1,1), (1,1,1))] = a_3[1,1,1]
            @test eltype(similar(BA_3, Float32)) == Float32
            q = rand(1,4,2)
            BA_3[Block(1,2,2)] = q
            @test BA_3[Block(1,2,2)] == q
            if BlockType == PseudoBlockArray
                q3 = zero(q)
                copyto!(q3, view(BA_3, Block(1, 2, 2)))
                @test q3 == q
            end
            fill!(BA_3, 1.0)
            @test BA_3 == ones(size(BA_3))
            ran = rand(size(BA_3)...)
            copyto!(BA_3, ran)
            @test BA_3 == ran
        end
    end

    @testset "convert" begin
        # Could probably be DRY'd.
        A = PseudoBlockArray(rand(2,3), [1,1], [2,1])

        @test convert(AbstractMatrix{Float64}, A) ≡ convert(AbstractMatrix, A) ≡ A
        @test convert(AbstractArray{Float64}, A) ≡ convert(AbstractArray, A) ≡ A
        @test convert(AbstractMatrix{Float32}, A) == AbstractMatrix{Float32}(A)
        @test convert(AbstractArray{Float32}, A) == AbstractArray{Float32}(A)

        C = convert(BlockArray, A)
        @test C == A == BlockArray(A)
        @test eltype(C) == eltype(A)

        C = convert(BlockArray{Float32}, A)
        @test C ≈ A ≈ BlockArray(A)
        @test eltype(C) == Float32

        C = convert(BlockArray{Float32, 2}, A)
        @test C ≈ A ≈ BlockArray(A)
        @test eltype(C) == Float32

        Ã = PseudoBlockArray(rand(2,3), Fill(1,2), [2,1])
        @test convert(typeof(A), Ã) == Ã

        @test PseudoBlockArray(A, axes(Ã)) isa typeof(Ã)
        @test PseudoBlockArray(A, axes(Ã)) == A

        A = BlockArray(rand(2,3), [1,1], [2,1])

        @test convert(AbstractMatrix{Float64}, A) ≡ convert(AbstractMatrix, A) ≡ A
        @test convert(AbstractArray{Float64}, A) ≡ convert(AbstractArray, A) ≡ A
        @test convert(AbstractMatrix{Float32}, A) == AbstractMatrix{Float32}(A)
        @test convert(AbstractArray{Float32}, A) == AbstractArray{Float32}(A)

        C = convert(PseudoBlockArray, A)
        @test C == A == PseudoBlockArray(A)
        @test eltype(C) == eltype(A)

        C = convert(PseudoBlockArray{Float32}, A)
        @test C ≈ A ≈ PseudoBlockArray(A)
        @test eltype(C) == Float32

        C = convert(PseudoBlockArray{Float32, 2}, A)
        @test C ≈ A ≈ PseudoBlockArray(A)
        @test eltype(C) == Float32

        @test convert(BlockArray, A) === A
        @test convert(BlockArray{Float64}, A) === A
        @test convert(BlockMatrix{Float64}, A) === A
        @test convert(BlockMatrix{Float64,Matrix{Matrix{Float64}}}, A) === A
    end

    @testset "string" begin
        A = BlockArray(rand(4, 5), [1,3], [2,3]);
        buf = IOBuffer()
        Base.showerror(buf, BlockBoundsError(A, (3,2)))
        @test String(take!(buf)) == "BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockMatrix{Float64, Matrix{Matrix{Float64}}, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}} at block index [3,2]"

        A = PseudoBlockArray(rand(4, 5), [1,3], [2,3]);
        Base.showerror(buf, BlockBoundsError(A, (3,2)))
        @test String(take!(buf)) == "BlockBoundsError: attempt to access 2×2-blocked 4×5 PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}} at block index [3,2]"
    end

    @testset "replstring" begin
        @test stringmime("text/plain",BlockArray(collect(1:4), [1,3])) == "2-blocked 4-element BlockVector{$Int}:\n 1\n ─\n 2\n 3\n 4"
        @test stringmime("text/plain",PseudoBlockArray(collect(1:4), [1,3])) == "2-blocked 4-element PseudoBlockVector{$Int}:\n 1\n ─\n 2\n 3\n 4"
        @test stringmime("text/plain",BlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2])) == "2×2-blocked 4×4 BlockMatrix{$Int}:\n 1  5  │   9  13\n ──────┼────────\n 2  6  │  10  14\n 3  7  │  11  15\n 4  8  │  12  16"
        @test stringmime("text/plain",PseudoBlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2])) == "2×2-blocked 4×4 PseudoBlockMatrix{$Int}:\n 1  5  │   9  13\n ──────┼────────\n 2  6  │  10  14\n 3  7  │  11  15\n 4  8  │  12  16"
        @test stringmime("text/plain",BlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1])) == "2×2×2-blocked 2×2×2 BlockArray{$Int, 3}:\n[:, :, 1] =\n 1  3\n 2  4\n\n[:, :, 2] =\n 5  7\n 6  8"
        @test stringmime("text/plain",PseudoBlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1])) == "2×2×2-blocked 2×2×2 PseudoBlockArray{$Int, 3}:\n[:, :, 1] =\n 1  3\n 2  4\n\n[:, :, 2] =\n 5  7\n 6  8"
        design = zeros(Int16,6,9);
        A = BlockArray(design,[6],[4,5])
        @test stringmime("text/plain",A) == "1×2-blocked 6×9 BlockMatrix{Int16}:\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0"
        A = PseudoBlockArray(design,[6],[4,5])
        @test stringmime("text/plain",A) == "1×2-blocked 6×9 PseudoBlockMatrix{Int16}:\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0\n 0  0  0  0  │  0  0  0  0  0"
        D = PseudoBlockArray(Diagonal(1:3), [1,2], [2,1])
        @test stringmime("text/plain", D) == "2×2-blocked 3×3 $(PseudoBlockMatrix{Int, Diagonal{Int, UnitRange{Int}}, Tuple{BlockedUnitRange{Vector{Int}}, BlockedUnitRange{Vector{Int}}}}):\n 1  ⋅  │  ⋅\n ──────┼───\n ⋅  2  │  ⋅\n ⋅  ⋅  │  3"

        a = BlockArray{Int}(undef_blocks, [1,2])
        @test stringmime("text/plain", a) == "2-blocked 3-element BlockVector{Int64}:\n #undef\n ──────\n #undef\n #undef"
        B = BlockArray{Int}(undef_blocks, [1,2], [1,1])
        @test stringmime("text/plain", B) == "2×2-blocked 3×2 BlockMatrix{Int64}:\n #undef  │  #undef\n ────────┼────────\n #undef  │  #undef\n #undef  │  #undef"
    end

    @testset "AbstractVector{Int} blocks" begin
        A = BlockArray(ones(6,6), 1:3, 1:3)
        @test A[1,1] == 1
        @test A[Block(2,3)] == ones(2,3)

        A = BlockArray(undef_blocks, Matrix{Float64}, 1:3, 1:3)
        A[Block(2,3)] = ones(2,3)
        @test A[Block(2,3)] == ones(2,3)
    end

    @testset "Strided array interface" begin
        A = PseudoBlockArray{Float64}(undef, 1:3, 1:3)
        fill!(A, 1)
        @test strides(A) == (1, size(A,1))
        x = randn(size(A,2))
        y = similar(x)
        @test BLAS.gemv!('N', 2.0, A, x, 0.0, y) ≈ 2A*x
    end

    @testset "lmul!/rmul!" begin
        A = PseudoBlockArray{Float64}(undef, 1:3)
        @test fill!(A, NaN) === A
        @test all(isnan, lmul!(0.0, copy(A))) == all(isnan, lmul!(0.0, Array(A)))
        @test lmul!(false, copy(A)) == lmul!(false, Array(A))
        @test lmul!(0.0, A) === A
        @test fill!(A, NaN) === A
        @test all(isnan, rmul!(copy(A), 0.0)) == all(isnan, rmul!(Array(A), 0.0))
        @test rmul!(copy(A), false) == rmul!(Array(A), false)
        @test rmul!(A, 0.0) === A

        A = BlockArray{Float64}(undef, 1:3)
        @test fill!(A, NaN) === A
        @test all(isnan, lmul!(0.0, copy(A))) == all(isnan, lmul!(0.0, Array(A)))
        @test lmul!(false, copy(A)) == lmul!(false, Array(A))
        @test lmul!(0.0, A) === A
        @test fill!(A, NaN) === A
        @test all(isnan, rmul!(copy(A), 0.0)) == all(isnan, rmul!(Array(A), 0.0))
        @test rmul!(copy(A), false) == rmul!(Array(A), false)
        @test rmul!(A, 0.0) === A
    end

    @testset "copy" begin
        A = PseudoBlockArray(randn(6), 1:3)
        B = copy(A)
        @test typeof(A) == typeof(B)
        @test axes(A) === axes(B)
        @test A == B
        B[1] = 2
        @test B[1] == 2
        @test A[1] ≠ 2

        A = BlockArray(randn(6), 1:3)
        B = copy(A)
        @test typeof(A) == typeof(B)
        @test axes(A) === axes(B)
        @test A == B
        B[1] = 2
        @test B[1] == 2
        @test A[1] ≠ 2
        @testset "copyto!" begin
            A = PseudoBlockArray(randn(6), 1:3)
            B = BlockArray(randn(6), 1:3)
            @test copyto!(BlockArray{Float64}(undef, 1:3), A) == A
            @test copyto!(PseudoBlockArray{Float64}(undef, 1:3), A) == A

            @test copyto!(BlockArray{Float64}(undef, 1:3), B) == B
            @test copyto!(PseudoBlockArray{Float64}(undef, 1:3), B) == B
        end
    end

    @testset "const block size" begin
        N = 10
        A = mortar(fill([1,2], N), Fill(2,N))
        B = PseudoBlockArray(vcat(fill([1,2], N)...),  Fill(2,N))
        @test A == vcat(A.blocks...) == B
        @test A[Block(1)] == B[Block(1)] == [1,2]
    end

    @testset "mixed blocks #92" begin
        A = BlockArray{Any}(undef_blocks, [1,2], [3,2])
        A.blocks[1,1] = fill(1.0,1,3)
        A.blocks[1,2] = fill(2,1,2)
        A.blocks[2,1] = fill(3//3,2,3)
        A.blocks[2,2] = fill(4.0f0,2,2)
        @test A[1,1] == 1.0
        @test A[2,1] == 1//1

        B = Matrix{Matrix}(undef,2,2)
        B[1,1] = fill(1.0,1,3)
        B[1,2] = fill(2,1,2)
        B[2,1] = fill(3//3,2,3)
        B[2,2] = fill(4.0f0,2,2)
        @test mortar(B) == A
        @test mortar(B)[1,1] == 1.0
    end

    @testset "reshape" begin
        A = BlockArray(1:6, 1:3)
        @test reshape(A, Val(2)) isa PseudoBlockArray{Int,2,Matrix{Int},Tuple{typeof(axes(A,1)),Base.OneTo{Int}}}
        @test reshape(A, Val(2)) == PseudoBlockArray(reshape(1:6,6,1), (blockedrange(1:3), Base.OneTo(1)))
        @test reshape(A, (blockedrange(Fill(2,3)),))[Block(1)] == 1:2
        @test reshape(A, 2, 3) == reshape(A, Base.OneTo(2), 3) == reshape(Vector(A), 2, 3)

        @test_throws DimensionMismatch reshape(A,3)

        A = PseudoBlockArray(1:6, 1:3)
        @test reshape(A, Val(2)) isa typeof(PseudoBlockArray(reshape(1:6,6,1), (blockedrange(1:3), Base.OneTo(1))))
        @test reshape(A, Val(2)) == PseudoBlockArray(reshape(1:6,6,1), (blockedrange(1:3), Base.OneTo(1)))
        @test reshape(A, (blockedrange(Fill(2,3)),))[Block(1)] == 1:2
        @test reshape(A, 2, 3) == reshape(A, Base.OneTo(2), 3) == reshape(Vector(A), 2, 3)
    end

    @testset "*" begin
        A = BlockArray(randn(6,6), 1:3,1:3)
        Ã = PseudoBlockArray(A)
        b = randn(6)
        @test A*b isa PseudoBlockVector{Float64}
        @test Ã*b isa PseudoBlockVector{Float64}
        @test A*b ≈ Ã*b ≈ Matrix(A)*b
    end

    @testset "Blockindex" begin
        a = PseudoBlockArray(randn(3), [1,2])
        @test a[Block(1)[1]] == a[1]
        @test a[Block(1)[1:1]] == a[1:1]
        A = PseudoBlockArray(randn(3,3), [1,2], [1,2])
        @test A[Block(1)[1], Block(1)[1]] == A[Block(1,1)[1,1]] == A[1,1]
        @test A[Block(1)[1:1], Block(1)[1:1]] == A[Block(1,1)[1:1,1:1]] == A[1:1,1:1]
        @test A[Block(1)[1:1], Block(1)[1]] == BlockArray(A)[Block(1)[1:1], Block(1)[1]] == A[1:1,1]
        @test A[Block(1)[1], Block(1)[1:1]] == BlockArray(A)[Block(1)[1], Block(1)[1:1]] == A[1,1:1]
    end

    @testset "permutedims" begin
        for a in (BlockArray(randn(3), [1,2]), PseudoBlockArray(randn(3), [1,2]))
            @test permutedims(a) == permutedims(Vector(a))
            blockisequal(axes(permutedims(a),2), axes(a,1))
        end

        for A in (BlockArray(randn(3,6), [1,2], 1:3), PseudoBlockArray(randn(3,6), [1,2], 1:3))
            @test permutedims(A) == permutedims(Matrix(A))
            blockisequal(axes(permutedims(A)), axes(A))
        end
    end

    @testset "adjoint getindex" begin
        a = BlockVector(1:5, [2,1,1,1])
        @test similar(a', Int, 1, axes(a,1)) isa BlockMatrix
        @test (a')[:,Block.(1:2)] == transpose(a)[:,Block.(1:2)] == [1 2 3]
        @test (a')[:,Block.(1:2)] isa Adjoint
        @test transpose(a)[:,Block.(1:2)] isa Transpose
    end

    @testset "empty blocklengths" begin
        A = BlockVector{Float64}(undef,Int[])
        @test @inferred(isempty(blocklengths(axes(A,1))))
    end

    @testset "pretty-printing" begin
        v = Zeros(3)
        m = mortar([v])
        io = IOBuffer()
        Base.print_array(io, m)
        s1 = String(take!(io))
        Base.print_array(io, v)
        s2 = String(take!(io))
        @test s1 == s2

        d = Diagonal(Ones(2,2))
        m = mortar(reshape([d], 1, 1))
        Base.print_array(io, m)
        s1 = String(take!(io))
        Base.print_array(io, d)
        s2 = String(take!(io))
        @test s1 == s2
    end

    @testset "Array indexing" begin
        a = randn(6)
        A = randn(6,3)
        @test a[blockedrange(1:3)] isa PseudoBlockVector
        @test A[blockedrange(1:3),:] isa PseudoBlockMatrix
        @test A[:,blockedrange(1:2)] isa PseudoBlockMatrix
        @test A[blockedrange(1:3),blockedrange(1:2)] isa PseudoBlockMatrix
    end

    @testset "resize!" begin
        a = PseudoBlockVector(collect(1:6), 1:3)
        b = resize!(a,Block(2))
        @test b == 1:3
        @test_throws BoundsError a[4] # length of a.blocks has changed
        c = resize!(b,Block(0))
        @test isempty(c)

        a = BlockVector(collect(1:6), 1:3)
        b = resize!(a,Block(2))
        @test b == 1:3
        @test_throws BoundsError a[4] # length of a.blocks has changed
        c = resize!(b,Block(0))
        @test isempty(c)
    end
end


text:
function Grid=HexagonGrid(nx,nz,lenx,lenz,Orient)
[Points,Faces,Cells]=Grid2DCFP(nx,nz,'hex',lenx,lenz);
Grid=CFPToGrid(Points,Faces,Cells,Orient);
end


text:
using Drawing
using Cairo

context(Axes(centred=true), Scale(1/200)) do cr

    save(cr)
    select_font_face (cr, "Sans", Cairo.FONT_SLANT_NORMAL,
                      Cairo.FONT_WEIGHT_BOLD)
    set_font_size (cr, 90.0)

    move_to (cr, 10.0, 135.0)
    show_text (cr, "Hello")

    move_to (cr, 70.0, 165.0)
    text_path (cr, "void")
    set_source_rgb (cr, 0.5, 0.5, 1)
    fill_preserve (cr)
    set_source_rgb (cr, 0, 0, 0)
    set_line_width (cr, 2.56)
    stroke (cr)

    # draw helping lines
    set_source_rgba (cr, 1, 0.2, 0.2, 0.6)
    arc (cr, 10.0, 135.0, 5.12, 0, 2*pi)
    close_path (cr)
    arc (cr, 70.0, 165.0, 5.12, 0, 2*pi)
    fill (cr)

    ## mark picture with current date
    restore(cr)
    move_to(cr,0.0,12.0)
    set_source_rgb (cr, 0,0,0)
    show_text(cr, strftime(time()))

end


text:
function _precompile_()
    ccall(:jl_generating_output, Cint, ()) == 1 || return nothing

    code = readstring(joinpath(dirname(@__FILE__), "parser.jl"))
    buf = IOBuffer(code)
    ts = Lexer.TokenStream{Tokens.Token}(buf)
    while !Lexer.eof(ts); Parser.parse(ts); end
    seekstart(buf)
    ts = Lexer.TokenStream{Tokens.SourceLocToken}(buf)
    while !Lexer.eof(ts); Parser.parse(ts); end

    precompile(JuliaParser.Parser.parse_resword, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken, Void,))
    precompile(JuliaParser.LineNumbers.Type, (Type{JuliaParser.LineNumbers.SourceFile}, String,))
    precompile(JuliaParser.Parser.not_eof_1, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser._parse_atom, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_call_chain, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceExpr, Bool,))
    precompile(JuliaParser.LineNumbers.compute_line, ( JuliaParser.LineNumbers.SourceFile, UInt32,))
    precompile(JuliaParser.Lexer.isuws, ( Char,))
    precompile(JuliaParser.Tokens.expr_append!, ( JuliaParser.Tokens.SourceExpr, Tuple{JuliaParser.Tokens.SourceExpr},))
    precompile(JuliaParser.Lexer.disallow_dot!, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Array{Char, 1}, JuliaParser.Tokens.SourceRange,))
    precompile(JuliaParser.Parser.parse_call_chain, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken, Bool,))
    precompile(JuliaParser.Parser.parse_block, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Any,))
    precompile(JuliaParser.Parser.parse_Nary, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_eq), Base.Set{Char}, Symbol, Base.Set{Symbol}, Bool, Void,))
    precompile(JuliaParser.Lexer.is_cat_id_start, ( Char, Int32,))
    precompile(JuliaParser.Lexer.read_number, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Bool, Bool,))
    precompile(JuliaParser.Parser._parse_arglist, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Char, Void,))
    precompile(JuliaParser.Parser.not_eof_3, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_comma_sep, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_eqs),))
    precompile(JuliaParser.LineNumbers.Type, (Type{JuliaParser.LineNumbers.SourceFile}, String,))
    precompile(JuliaParser.Parser.parse_iteration_spec, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_import_dots, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Tokens.expr_append!, ( JuliaParser.Tokens.SourceExpr, JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.Tokens.expr_append!, ( JuliaParser.Tokens.SourceExpr, Tuple{},))
    precompile(JuliaParser.Parser.separate, (typeof( JuliaParser.Parser.is_parameter), Array{Any, 1},))
    precompile(JuliaParser.Parser.parse_Nary, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_cond), Base.Set{Char}, Symbol, Base.Set{Any}, Bool, Void,))
    precompile(JuliaParser.Parser.to_kws, ( Array{Any, 1},))
    precompile(JuliaParser.Parser.parse_range, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_space_separated_exprs, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_RtoL, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Any, Base.Set{Symbol}, JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.LineNumbers.getindex, ( JuliaParser.LineNumbers.SourceFile, Int64,))
    precompile(JuliaParser.Parser.parse_assignment, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_cond),))
    precompile(JuliaParser.Lexer.utf8sizeof, ( Char,))
    precompile(JuliaParser.Lexer.require_token, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Bool,))
    precompile(JuliaParser.Diagnostics.diag, ( JuliaParser.Diagnostics.Diagnostic, JuliaParser.Tokens.SourceRange, String,))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_arrow), Base.Set{Symbol},))
    precompile(JuliaParser.Parser._parse_arglist, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Char, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Tokens.expr_append!, ( JuliaParser.Tokens.SourceExpr, Array{Any, 1},))
    precompile(JuliaParser.Parser.parse_Nary, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Any, Base.Set{Char}, Symbol, Base.Set{Any}, Bool,))
    precompile(JuliaParser.Diagnostics.normalize_loc, ( JuliaParser.Tokens.SourceRange,))
    precompile(JuliaParser.Parser.not_eof_2, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Lexer.is_identifier_char, ( Char,))
    precompile(JuliaParser.Tokens.expr_append!, ( JuliaParser.Tokens.SourceExpr, Array{JuliaParser.Tokens.SourceExpr, 1},))
    precompile(JuliaParser.Parser.parse_assignment, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Any, JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.Tokens.expr_append!, ( JuliaParser.Tokens.SourceExpr, Tuple{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Tokens.expr_append!, ( JuliaParser.Tokens.SourceExpr, Tuple{JuliaParser.Tokens.SourceExpr, JuliaParser.Tokens.SourceExpr},))
    precompile(JuliaParser.Lexer.next_token, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Bool,))
    precompile(JuliaParser.Parser._parse_string_literal, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Symbol, Int64, Bool,))
    precompile(JuliaParser.Parser.parse_unary, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_string_literal, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Bool,))
    precompile(JuliaParser.Tokens.merge, ( JuliaParser.Tokens.SourceNode, JuliaParser.Tokens.SourceNode,))
    precompile(JuliaParser.Parser.macroify_name, ( JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.short_form_function_loc, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceExpr, Int64, Symbol,))
    precompile(JuliaParser.Parser.parse_Nary, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Any, Base.Set{Char}, Symbol, Base.Set{Symbol}, Bool,))
    precompile(JuliaParser.Parser.expect_end, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Tokens.val, ( LineNumberNode,))
    precompile(JuliaParser.Parser.short_form_function_loc, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken, Int64, Symbol,))
    precompile(JuliaParser.Parser.is_closing_token, ( JuliaParser.Parser.ParseState, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Tokens.merge, ( JuliaParser.Tokens.SourceRange, JuliaParser.Tokens.SourceRange,))
    precompile(JuliaParser.Tokens.make_zip, ( JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.Parser.parse_juxtaposed, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Tokens.merge, ( JuliaParser.Tokens.SourceRange, JuliaParser.Tokens.SourceNode,))
    precompile(JuliaParser.Parser.is_juxtaposed, ( JuliaParser.Parser.ParseState, JuliaParser.Tokens.SourceExpr, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Lexer.peekchar, ( Base.AbstractIOBuffer{Array{UInt8, 1}},))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_range), Base.Set{Symbol}, JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.Parser.is_juxtaposed, ( JuliaParser.Parser.ParseState, JuliaParser.Tokens.SourceLocToken, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_term), Base.Set{Symbol}, JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.Parser.tostr, ( Base.AbstractIOBuffer{Array{UInt8, 1}}, Bool,))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_range), Base.Set{Symbol}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_comparison, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Base.Set{Symbol},))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_unary), Base.Set{Symbol}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_term), Base.Set{Symbol}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_unary), Base.Set{Symbol}, JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.Parser.arglist_to_tuple, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Bool, Bool, Array{Any, 1}, Tuple{},))
    precompile(JuliaParser.Lexer.readchar, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_RtoL, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Any, Base.Set{Symbol}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_assignment, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Any, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_import, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_cond, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_backquote, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_comma_sep, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_unary_prefix),))
    precompile(JuliaParser.Parser.parse_juxtaposed, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.Parser.subtype_syntax, ( JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.LineNumbers.compute_line, ( JuliaParser.LineNumbers.SourceFile, UInt64,))
    precompile(JuliaParser.Parser.parse_decl, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.add_filename_to_block!, ( JuliaParser.Tokens.SourceExpr, LineNumberNode,))
    precompile(JuliaParser.Parser.subtype_syntax, ( JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_imports, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_with_chains, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_rational), Base.Set{Symbol}, Symbol,))
    precompile(JuliaParser.Parser.parse_with_chains, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_shift), Base.Set{Symbol}, Symbol,))
    precompile(JuliaParser.Lexer.take_token, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.is_doc_string_literal, ( JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.Parser.parse_factorh, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_unary), Base.Set{Symbol},))
    precompile(JuliaParser.Lexer.peek_token, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Bool,))
    precompile(JuliaParser.Parser.parse_arrow, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_atom, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Lexer.read_operator, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Char, Int64,))
    precompile(JuliaParser.Lexer.is_zero_width_space, ( Char,))
    precompile(JuliaParser.Lexer.accum_julia_symbol, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Char,))
    precompile(JuliaParser.Parser.parse_or, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_docstring, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_eq),))
    precompile(JuliaParser.Tokens.merge, ( JuliaParser.Tokens.SourceExpr, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Lexer.skip_multiline_comment, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Int64,))
    precompile(JuliaParser.Parser.parse_comma_sep_iters, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Tokens.merge, ( Expr, JuliaParser.Tokens.SourceRange,))
    precompile(JuliaParser.Parser.parse_arglist, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Char, Void,))
    precompile(JuliaParser.Parser.parse_stmts, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_interpolate, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceRange, JuliaParser.Tokens.SourceRange,))
    precompile(JuliaParser.Parser.parse_call, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_arglist, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Char, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Lexer.make_token, ( Type{JuliaParser.Tokens.SourceLocToken}, Symbol, Int64, Int64,))
    precompile(JuliaParser.Tokens.merge, ( JuliaParser.Tokens.SourceLocToken, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_unary_prefix, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.is_invalid_initial_token, ( Symbol,))
    precompile(JuliaParser.Lexer.is_syntactic_unary_op, ( Symbol,))
    precompile(JuliaParser.Parser.is_invalid_initial_token, ( Char,))
    precompile(JuliaParser.Tokens.normalize, ( JuliaParser.Tokens.SourceNode,))
    precompile(JuliaParser.Lexer.is_operator, ( Symbol,))
    precompile(JuliaParser.Parser.parse, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Tokens.Type, (Type{JuliaParser.Tokens.SourceNode}, JuliaParser.Tokens.SourceRange, Array{JuliaParser.Tokens.SourceNode, 1},))
    precompile(JuliaParser.Tokens.Type, (Type{JuliaParser.Tokens.SourceLocToken}, Symbol, JuliaParser.Tokens.SourceRange,))
    precompile(JuliaParser.Lexer.skipws, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, Bool,))
    precompile(JuliaParser.Lexer.set_token!, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Parser.parse_resword, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken}, JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Tokens.Type, (Type{JuliaParser.Tokens.SourceNode}, JuliaParser.Tokens.SourceNode,))
    precompile(JuliaParser.Tokens.normalize, ( JuliaParser.Tokens.SourceRange,))
    precompile(JuliaParser.Lexer.isnewline, ( JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Lexer.eof, ( JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Lexer.is_operator, ( Char,))
    precompile(JuliaParser.Lexer.isnewline, ( Char,))
    precompile(JuliaParser.Tokens.val, ( JuliaParser.Tokens.SourceLocToken,))
    precompile(JuliaParser.Tokens.Type, (Type{JuliaParser.Tokens.SourceRange}, UInt32, UInt32, UInt8,))
    precompile(JuliaParser.Lexer.is_operator, ( Expr,))
    precompile(JuliaParser.Tokens.val, ( JuliaParser.Tokens.SourceExpr,))
    precompile(JuliaParser.Tokens.Type, (Type{JuliaParser.Tokens.SourceExpr}, Symbol, JuliaParser.Tokens.SourceNode,))
    precompile(JuliaParser.LineNumbers.getindex, ( JuliaParser.LineNumbers.SourceFile, Base.UnitRange{Int64},))
    precompile(JuliaParser.Parser.parse_factorh, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_decl), Base.Set{Symbol},))
    precompile(JuliaParser.Tokens.Type, (Type{JuliaParser.Tokens.SourceExpr}, LineNumberNode, JuliaParser.Tokens.SourceNode,))
    precompile(JuliaParser.Tokens.Type, (Type{JuliaParser.Tokens.SourceExpr}, Expr, JuliaParser.Tokens.SourceNode,))
    precompile(JuliaParser.Tokens.children, ( JuliaParser.Tokens.SourceNode,))
    precompile(JuliaParser.Diagnostics.before, ( JuliaParser.Tokens.SourceRange,))
    precompile(JuliaParser.Parser.parse_eqs, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Lexer.skipcomment, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Lexer.eof, ( Char,))
    precompile(JuliaParser.Lexer.eof, ( Symbol,))
    precompile(JuliaParser.Lexer.isnewline, ( Symbol,))
    precompile(JuliaParser.Parser.parse_eq, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_RtoL, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_and), Base.Set{Symbol},))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_range), Base.Set{Symbol},))
    precompile(JuliaParser.Lexer.skipws_and_comments, ( JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_RtoL, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_or), Base.Set{Symbol},))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_unary), Base.Set{Symbol},))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_pipes), Base.Set{Symbol},))
    precompile(JuliaParser.Parser.parse_LtoR, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_term), Base.Set{Symbol},))
    precompile(JuliaParser.Parser.parse_RtoL, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_comparison), Base.Set{Symbol},))
    precompile(JuliaParser.Parser.parse_comma, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_term, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_expr, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_assignment, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},typeof( JuliaParser.Parser.parse_comma),))
    precompile(JuliaParser.Lexer.is_ignorable_char, ( Char,))
    precompile(JuliaParser.Parser.parse_pipes, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_comparison, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_factor, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_in, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_rational, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Parser.parse_shift, ( JuliaParser.Parser.ParseState, JuliaParser.Lexer.TokenStream{JuliaParser.Tokens.SourceLocToken},))
    precompile(JuliaParser.Lexer.is_identifier_start_char, ( Char,))

    nothing
end


text:
"""
    buildA(hh, qcols, neq)

Build the companion matrix, deleting inessential lags.
Solve for x_{t+nlead} in terms of x_{t+nlag},...,x_{t+nlead-1}.

"""
function buildA!(hh::Array{Float64,2}, qcols::Int64, neq::Int64)

    left  = 1:qcols
    right = (qcols + 1):(qcols + neq)

    tmp = similar(hh)
    tmp[:, left] =  \(-hh[:, right], hh[:, left])

    #  Build the big transition matrix.
    aa = zeros(qcols, qcols)

    if(qcols > neq)
        eyerows = 1:(qcols - neq)
        eyecols = (neq + 1):qcols
        # aa[eyerows, eyecols] = eye(qcols - neq)
	aa[eyerows, eyecols] = Compat.Matrix(I, qcols - neq, qcols - neq)
    end
    hrows      = (qcols - neq + 1):qcols
    aa[hrows, :] =  tmp[:, left]

    #  Delete inessential lags and build index array js.  js indexes the
    #  columns in the big transition matrix that correspond to the
    #  essential lags in the model.  They are the columns of q that will
    #  get the unstable left eigenvectors.

    js       = Array{Int64}(undef, 1, qcols)
    for ii in 1 : qcols
        js[1, ii] = ii
    end

    zerocols = Compat.sum(abs.(aa); dims=1)
    zerocols = LinearIndices(zerocols)[findall(col->(col == 0), zerocols)]

     while length(zerocols) != 0
        # aa = filter!(x->(x !in zerocols), aa)
        aa = deleteCols(aa, zerocols)
        aa = deleteRows(aa, zerocols)
        js = deleteCols(js, zerocols)

        zerocols = Compat.sum(abs.(aa); dims=1)
        zerocols = LinearIndices(zerocols)[findall(col->(col == 0), zerocols)]

    end
    ia = length(js)

    return (aa::Array{Float64,2}, ia::Int64, Int64.(js)::Array{Int64,2})

end # buildA